-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Undetected capture error with by-name parameters #21920
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
Labels
area:experimental:cc
Capture checking related
area:reporting
Error reporting including formatting, implicit suggestions, etc
itype:bug
Milestone
Comments
By-name parameters get mapped in ElimByName to context functions. That's why the two program logs should be almost the same. And they are, except for this "existential match not found" business. |
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 11, 2024
A by-name Closure node, which is produced by phase ElimByName gets a target type to indicate it's a contextual zero parameter closure. But for the purposes of rechecking and capture checking, it needs to be treated like a function. In particular the type of the closure needs to be derived from the result type of the anonymous function. Fixes scala#21920
Fixed by #21863 with the commit above |
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 11, 2024
A by-name Closure node, which is produced by phase ElimByName gets a target type to indicate it's a contextual zero parameter closure. But for the purposes of rechecking and capture checking, it needs to be treated like a function. In particular the type of the closure needs to be derived from the result type of the anonymous function. Fixes scala#21920
Merged
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 21, 2024
A by-name Closure node, which is produced by phase ElimByName gets a target type to indicate it's a contextual zero parameter closure. But for the purposes of rechecking and capture checking, it needs to be treated like a function. In particular the type of the closure needs to be derived from the result type of the anonymous function. Fixes scala#21920
KacperFKorban
pushed a commit
to dotty-staging/dotty
that referenced
this issue
Nov 29, 2024
A by-name Closure node, which is produced by phase ElimByName gets a target type to indicate it's a contextual zero parameter closure. But for the purposes of rechecking and capture checking, it needs to be treated like a function. In particular the type of the closure needs to be derived from the result type of the anonymous function. Fixes scala#21920
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:experimental:cc
Capture checking related
area:reporting
Error reporting including formatting, implicit suggestions, etc
itype:bug
Compiler version
3.6.1, PR
Minimized example
Output
compiles
Expectation
Should give an error, as in the slightly changed version where we replace by-name with explicit functions:
This gives:
I searched for a long time without getting to the root cause. What I did:
I compiled both programs with the first called
unsound-byname.scala
and the second calledunsound-byname-2.scala
with the following commands:I then diffed the test output. There were several rabbit holes which were unproductive.
[R] -> () -> R
during setup while the first did not. It turned out this was because the second program uses an alias type while the first used the alias directly.The one difference that remained was that the unsound program
unsound-byname.scala
produced several error messages of the formwhere the other one did not. Something is inconsistent with existentials and that leads to errors being suppressed. I tried to dig deeper but could not find anything conclusive.
The text was updated successfully, but these errors were encountered: