effekt-lang / effekt-lang/effekt

Unhelpful error message when subtracting numbers without spaces

Open
#1,164 3 comments 0 reactions 0 assignees View on GitHub
errormessage
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

The following code does not compile:
```effekt
def main() = {
println(1-2)
}
```
And produces the following error
```shell
Expected ) but got integer -2
println(1-2)
^^
```

Although not tested, its probably because the `-` character gets included in the number literal, as indicated by the error.

I think [this line](https://github.com/effekt-lang/effekt/blob/664897873ec95088b0e8d51a2895208143aef1e9/effekt/shared/src/main/scala/effekt/Lexer.scala#L433) could be removed and [matchPattern()](https://github.com/effekt-lang/effekt/blob/664897873ec95088b0e8d51a2895208143aef1e9/effekt/shared/src/main/scala/effekt/Parser.scala#L964) altered to handle the extra `-` Token for literal patterns.

This would also allow spacing between the sign bit and the digits.

[Java also does not include the `-` for number literals](https://docs.oracle.com/javase/specs/jls/se25/html/jls-3.html#jls-3.10.1)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.