Skip to content
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

Error about Contextual function's parameter refer to its synthetic name without explantation #18188

Closed
Sporarum opened this issue Jul 11, 2023 · 4 comments · Fixed by #18788
Closed
Labels
area:implicits related to implicits area:infer area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug Spree Suitable for a future Spree

Comments

@Sporarum
Copy link
Contributor

Sporarum commented Jul 11, 2023

Compiler version

3.3.1-RC1

Minimized code

class A1[T](action: A1[T] ?=> String = "")

Output

-- [E081] Type Error: ----------------------------------------------------------
1 |class A1[T](action: A1[T] ?=> String = "")
  |                                       ^
  |                   Missing parameter type
  |
  |                   I could not infer the type of the parameter evidence$1.
  |                   What I could infer was: A1[<?>]
1 error found

Expectation

The error mentions evidence$1 which is not defined anywhere
(neither in user-facing code, nor in the error message)

This example was taken from tests/neg/i11350.scala in the compiler, but affects any AnonymousFunctionMissingParamType on contextual functions, and potentially other errors

@Sporarum Sporarum added itype:bug area:reporting Error reporting including formatting, implicit suggestions, etc area:implicits related to implicits area:infer labels Jul 11, 2023
@Sporarum Sporarum changed the title Error about Contextual function's parameter refer to synthetic name without explantation about its source Error about Contextual function's parameter refer to its synthetic name without explantation Jul 11, 2023
@Sporarum Sporarum added the Spree Suitable for a future Spree label Jul 11, 2023
@Sporarum
Copy link
Contributor Author

It should be relatively straightforward to fix at least for AnonymousFunctionMissingParamType

@Sporarum
Copy link
Contributor Author

Sporarum commented Jul 11, 2023

@smarter also talked about adding this behavior to the interpolator directly, which would be more challenging, but can still be interesting for spree pros

@bishabosha bishabosha added the better-errors Issues concerned with improving confusing/unhelpful diagnostic messages label Oct 10, 2023
@bishabosha
Copy link
Member

bishabosha commented Oct 10, 2023

as well as having a confusing error message, this seems to be a bug in inference because the following (obvious desugaring) type-checks without error:

class A1[T](action: A1[T] ?=> String = (a1: A1[T]) ?=> "")

@bishabosha
Copy link
Member

bishabosha commented Oct 10, 2023

perhaps we should make a separate issue about the infamous "I could not infer the type of the parameter foo$1" when using placeholder parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:implicits related to implicits area:infer area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants