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

Given error positioning is ambiguous and should mark the entire expression instead #21537

Open
soronpo opened this issue Sep 4, 2024 · 0 comments
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug

Comments

@soronpo
Copy link
Contributor

soronpo commented Sep 4, 2024

Given error positioning is only marking the end of the relevant expression. This leads to ambiguous reporting in infix expression and the error is not clear if it's the RHS argument error or the entire expression argument error.

Consider the example below. The given error positioning for x1 and x2 internal expressions are indistinguishable. Contrarily, the error positioning difference between x3 and x4 is very clear.

Compiler version

v3.5.0

Minimized code

trait Error
inline given Error  = compiletime.error("my error")
def foo(using Error): Int = 0
inline def bar: Int = compiletime.error("my error")
extension (arg: Int)
  def ~(arg2: Int)(using Error): Int = 0
  inline def !(arg2: Int): Int = compiletime.error("my error")

val x1 = 1 + (5 + foo) + 20
val x2 = 1 + (5 ~ 200) + 20
val x3 = 1 + (5 + bar) + 20
val x4 = 1 + (5 ! 200) + 20

Output

[error] .\IDTop.scala:9:22
[error] my error
[error] val x1 = 1 + (5 + foo) + 20
[error]                      ^
[error] .\IDTop.scala:10:22
[error] my error
[error] val x2 = 1 + (5 ~ 200) + 20
[error]                      ^
[error] .\IDTop.scala:11:19
[error] my error
[error] val x3 = 1 + (5 + bar) + 20
[error]                   ^^^
[error] .\IDTop.scala:12:15
[error] my error
[error] val x4 = 1 + (5 ! 200) + 20
[error]               ^^^^^^^

Expectation

When a given error occurs, it needs to mark the entire expression and not just the end of it, like seen in the x3 and x4 examples.

@soronpo soronpo added itype:bug area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages labels Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug
Projects
None yet
Development

No branches or pull requests

1 participant