Skip to content

Fix #10085: check if enum case confirms to scrutinee type #10094

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

Merged
merged 2 commits into from
Oct 30, 2020

Conversation

liufengyun
Copy link
Contributor

@liufengyun liufengyun commented Oct 27, 2020

Fix #10085: check if enum case confirms to scrutinee type
Fix #9190: infer union types

@liufengyun
Copy link
Contributor Author

test performance please

@dottybot
Copy link
Member

performance test scheduled: 6 job(s) in queue, 1 running.

@liufengyun liufengyun requested a review from smarter October 27, 2020 10:45
@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/10094/ to see the changes.

Benchmarks is based on merging with master (22c23a5)

@smarter
Copy link
Member

smarter commented Oct 27, 2020

The latest commit in this PR is:

Fix CI: add facility to infer union and singleton types

  • infer singleton types: tests/patmat/i4227.scala
  • infer union types: tests/patmat/i9190.scala
  • I checked out the previous commit and tried scala3-compiler/testOnly *PatmatExhaustivityTest and no test failed, how can I reproduce the problem?
  • tests/patmat/i9190.scala doesn't exist

@liufengyun
Copy link
Contributor Author

The latest commit in this PR is:

Fix CI: add facility to infer union and singleton types

  • infer singleton types: tests/patmat/i4227.scala
  • infer union types: tests/patmat/i9190.scala
  • I checked out the previous commit and tried scala3-compiler/testOnly *PatmatExhaustivityTest and no test failed, how can I reproduce the problem?

You can try testOnly -- *.patmatExhaustivity.

  • tests/patmat/i9190.scala doesn't exist

Good catch, it's now added.

@smarter
Copy link
Member

smarter commented Oct 27, 2020

You can try testOnly -- *.patmatExhaustivity.

I think that runs the same set of tests, anyway I tried it and I still don't get any error on commit 149d4de, (I do get an error for i9190 if I add it manually, but nothing for i4227)

@liufengyun
Copy link
Contributor Author

You can try testOnly -- *.patmatExhaustivity.

I think that runs the same set of tests, anyway I tried it and I still don't get any error on commit 149d4de, (I do get an error for i9190 if I add it manually, but nothing for i4227)

For i4227, we only get an error if we remove the following lines (removed in the 2nd commit):

          // force type inference to infer a narrower type: could be singleton
          // see tests/patmat/i4227.scala
          mt.paramInfos(0) <:< scrutineeTp

The code was there just to make type inference infer a singleton type.

@smarter
Copy link
Member

smarter commented Oct 27, 2020

I see, thanks. I was surprised that mt.paramInfos(0) <:< scrutineeTp didn't work for the union case, so I investigated and found that this was caused by a bug for which I made a PR: #10106. Once this is merged we shouldn't need c245d33 (we can separately discuss if this is still useful, but it wouldn't be needed for this PR).

@liufengyun
Copy link
Contributor Author

I see, thanks. I was surprised that mt.paramInfos(0) <:< scrutineeTp didn't work for the union case, so I investigated and found that this was caused by a bug for which I made a PR: #10106. Once this is merged we shouldn't need c245d33 (we can separately discuss if this is still useful, but it wouldn't be needed for this PR).

Thanks for going deep into the issue. Once that's merged, I'll rebase and drop the 2nd commit for now.

@smarter
Copy link
Member

smarter commented Oct 30, 2020

rebase and drop the 2nd commit for now.

Done.

@smarter smarter added this to the 3.0.0-M1 milestone Oct 30, 2020
@liufengyun
Copy link
Contributor Author

rebase and drop the 2nd commit for now.

Done.

Thanks, I also pushed some simplifications from the 2nd commit in 6a9c4ea.

@liufengyun liufengyun merged commit ea64026 into scala:master Oct 30, 2020
@liufengyun liufengyun deleted the fix-10085 branch October 30, 2020 14:38
@Kordyjan Kordyjan modified the milestones: 3.0.0-M1, 3.0.0 Aug 2, 2023
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.

Simple GADT giving "match may not be exhaustive" Exhaustivity checking on union types within product types is too restrictive
4 participants