Convert dangling comma into unexpected expression (#5776)

Test and fix for #5691.
This commit is contained in:
Jaroslav Tulach 2023-02-28 08:44:06 +01:00 committed by GitHub
parent 0536eeb0bb
commit a150abbea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -765,6 +765,9 @@ final class TreeToIr {
items = cons(exp, items);
for (var next : arr.getRest()) {
exp = translateExpression(next.getBody(), false);
if (exp == null) {
yield translateSyntaxError(arr, IR$Error$Syntax$UnexpectedExpression$.MODULE$);
}
items = cons(exp, items);
}
}

View File

@ -81,6 +81,13 @@ public class EnsoCompilerTest {
""", true, true, true);
}
@Test
public void testListWithATrailingComma() throws Exception {
parseTest("""
main = ["a", ]
""", true, true, true);
}
@Test
public void testLocationsDeeplyNestedFunctions() throws Exception {
parseTest("""