-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Detect InsertedApply on Apply to break synthetic apply loops, not just Select
#25463
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -- [E050] Type Error: tests/neg/24782.scala:4:28 ----------------------------------------------------------------------- | ||
| 4 | def f(using pure: Pure) = S(s => pure(s)) // error (but no compiler crash / stack overflow) | ||
| | ^ | ||
| | expression does not take more parameters | ||
| | | ||
| | longer explanation available when compiling with `-explain` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| object S { | ||
| trait F[A] | ||
| type Pure = [a] => a => F[a] | ||
| def f(using pure: Pure) = S(s => pure(s)) // error (but no compiler crash / stack overflow) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ object Module { | |
| case 1 => Any *: Fill[0] | ||
| } | ||
| extension[N <: Int] (f: Fun[N]) | ||
| def apply: Fill[N] => Any = ??? | ||
| def apply(): Fill[N] => Any = ??? | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So defining
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. per conversation on Slack, no, parameterless apply should not be used since the language reference only talks about parameterized insertions of apply, see the recent thread in compiler-development
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, then can we have a clear test that shows explicitly this. Something like: object A:
def apply: Int = ???
val x: Int = A // error: must call apply explicitlyThis test and the other have too many elements in them that it is not clear what their purpose is.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to have some systematic tests of language features, yeah, but for that we'd need an unambiguous language reference first, the slack thread already mentions some corner cases like "what if apply is of a custom function-like type". :/
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree. If that is intended to be the case, and if you find the wording to be ambiguous, you can also update the wording to at least cover this case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. created #25504 |
||
|
|
||
| Fun[1]()(???) | ||
| Fun[1]()()(???) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed on Slack, per §6.6 of the language ref, |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkfile is missing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, thanks, added