Skip to content

Quickly fix HKT GADT unsoundness issue #9138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

abgruszecki
Copy link
Contributor

@abgruszecki abgruszecki commented Jun 9, 2020

Check that the result of GADT approximation is actually a subtype of what we're approximating.

Fixes #9044.

Check that the result of GADT approximation is actually a subtype of
what we're approximating.
@abgruszecki
Copy link
Contributor Author

@smarter so it turns out that the issue was with GADT member healing! Can you take a look at the code? The relevant test passes on my local machine.

I'm just surprised that tpd.Typed(t, tpt) doesn't actually check that the type ascription is, well, an ascription. Let's consider after the release as to why GADT approximation (and type variable forcing, by extension) creates types that aren't actual subtypes of what we're approximating.

@smarter
Copy link
Member

smarter commented Jun 9, 2020

I'm just surprised that tpd.Typed(t, tpt) doesn't actually check that the type ascription is, well, an ascription.

TreeChecker should check that but doesn't, I have a branch which fixes that but it needs more work because it revealed situations where this isn't true currently.

// otherwise fail with the error that would have been reported without the GADT recovery
err.typeMismatch(tree, pt, failure)
val approximated = Inferencing.approximateGADT(wtp)(using nestedCtx)
if (tree.tpe <:< approximated) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that check be done in the nestedCtx?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's sadly not the part that's making it explode. Not even making the check frozen and doing it in nestedCtx helps. I have no idea why, seems that we will need to take a more scorched-earth type of approach.

@abgruszecki abgruszecki closed this Jun 9, 2020
@abgruszecki abgruszecki deleted the fix-9044.scala branch June 9, 2020 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify HKT GADT code
2 participants