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

Improve error messages for erroneous export statements #21976

Open
KacperFKorban opened this issue Nov 19, 2024 · 0 comments
Open

Improve error messages for erroneous export statements #21976

KacperFKorban opened this issue Nov 19, 2024 · 0 comments
Labels
area:export area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement

Comments

@KacperFKorban
Copy link
Member

Compiler version

3a5e137

Minimized example

def fun1(i: Int): Double = ???
  
def fun2(d: Double): Double = ???

export fun1.apply, fun2.unlift

Output Error/Warning message

-- [E083] Type Error: /home/kpi/bugs/export-better-errors.scala:5:7 ------------
5 |export fun1.apply, fun2.unlift
  |       ^^^^
  |Int => Double is not a valid export prefix, since it is not an immutable path
  |
  | longer explanation available when compiling with `-explain`
-- [E083] Type Error: /home/kpi/bugs/export-better-errors.scala:5:19 -----------
5 |export fun1.apply, fun2.unlift
  |                   ^^^^
  |       Any is not a valid export prefix, since it is not an immutable path
  |
  | longer explanation available when compiling with `-explain`
-- Error: /home/kpi/bugs/export-better-errors.scala:5:24 -----------------------
5 |export fun1.apply, fun2.unlift
  |                        ^^^^^^
  |                        no eligible member unlift at {
  |                          def $anonfun(d: Double): Double = fun2(d)
  |                          closure($anonfun:Any)
  |                        }

Why this Error/Warning was not helpful

The first error message is helpful, but the rest are confusing. Any is inferred for fun2 most likely because of the previous error, and the last error shows some desugared/eta-expanded code, which is also a side effect of the previous error.

Suggested improvement

The last error shouldn't be shown. One possibility is to make the positions the same for the first and last errors.

@KacperFKorban KacperFKorban added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc stat:needs triage Every issue needs to have an "area" and "itype" label better-errors Issues concerned with improving confusing/unhelpful diagnostic messages and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:export area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement
Projects
None yet
Development

No branches or pull requests

2 participants