Skip to content

Conversation

Sporarum
Copy link
Contributor

@Sporarum Sporarum commented Jul 11, 2023

We fixed the issue, as well as hopefully improved the existing error

Done with @sankalpgambhir

@Sporarum Sporarum added the Spree Suitable for a future Spree label Jul 11, 2023
@dwijnand dwijnand changed the title Fix i18042 Improve parameter type inference error messaging Jul 11, 2023
@@ -1,14 +1,18 @@
-- [E081] Type Error: tests/neg/i17183.scala:11:24 ---------------------------------------------------------------------
11 |def test = Context(f = (_, _) => ???) // error // error
| ^
| Missing parameter type
| Could not infer type for parameter _$1 of anonymous function
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would be possible to report

 Could not infer type for the 1st parameter of an anonymous function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be possible, but I'm not sure it's desirable, I think here we need to show some internals

Copy link
Contributor

Choose a reason for hiding this comment

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

The internal names of _ and other unamed variables are only useful to us. Never to the user as they cannot use them in the source.

Copy link
Contributor Author

@Sporarum Sporarum Jul 13, 2023

Choose a reason for hiding this comment

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

I agree, but we need to show the desugarring anyways, as the issue might be that the user missunderstood how _ works
And therefore need names in the desugarring (but these could be something else than _$1)

@nicolasstucki nicolasstucki self-assigned this Jul 13, 2023
@Sporarum Sporarum requested a review from nicolasstucki July 18, 2023 13:46
@nicolasstucki nicolasstucki merged commit b7e797d into scala:main Jul 18, 2023
@nicolasstucki nicolasstucki deleted the fix-i18042 branch July 18, 2023 14:22
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Kordyjan added a commit that referenced this pull request Dec 8, 2023
…19119)

Backports #18190 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
@Kordyjan Kordyjan modified the milestones: 3.4.0, 3.3.2 Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler is overly secretive when it fails to infer the type of parameters
3 participants