Syntax error on unexpected unary minus (#8333)

This commit is contained in:
Jaroslav Tulach 2023-11-20 16:14:19 +01:00 committed by GitHub
parent 375e610660
commit 705d6f192c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -961,6 +961,7 @@ final class TreeToIr {
var arg = new CallArgument.Specified(Option.empty(), expr, expr.location(), meta(), diag());
yield new Application.Prefix(negate, join(arg, nil()), false, expr.location(), meta(), diag());
}
case null -> translateSyntaxError(tree, new Syntax.UnsupportedSyntax("Strange unary -"));
};
case Tree.TypeSignature sig -> {
var methodName = buildName(sig.getVariable());

View File

@ -30,6 +30,17 @@ public class ErrorCompilerTest extends CompilerTest {
assertSingleSyntaxError(ir, Syntax.InvalidUnderscore$.MODULE$, "Invalid use of _", 14, 15);
}
@Test
public void unaryMinus() throws Exception {
var ir = parse("""
from Standard.Base import all
main = Date.new day=-
""");
assertSingleSyntaxError(ir, new Syntax.UnsupportedSyntax("Strange unary -"), "Syntax is not supported yet: Strange unary -", 51, 52);
}
@Test
public void dotUnderscore2() throws Exception {
var ir = parse("""