Turn null into UnexpectedExpression when Union type is incomplete (#6415)

Test and fix for #6401.
This commit is contained in:
Jaroslav Tulach 2023-04-25 16:49:26 +02:00 committed by GitHub
parent b8f075a178
commit 63de18e367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -1084,6 +1084,9 @@ final class TreeToIr {
}
case Tree.OprApp app -> {
var op = app.getOpr().getRight();
if (op == null) {
yield translateSyntaxError(app, IR$Error$Syntax$UnexpectedExpression$.MODULE$);
}
yield switch (op.codeRepr()) {
case "." -> {
final Option<IdentifiedLocation> loc = getIdentifiedLocation(tree);

View File

@ -192,6 +192,14 @@ public class ErrorCompilerTest extends CompilerTest {
assertSingleSyntaxError(ir, IR$Error$Syntax$UnexpectedExpression$.MODULE$, "Unexpected expression", 0, 20);
}
@Test
public void malformedTypeException() throws Exception {
var ir = parse("""
fan_out_to_columns : Table -> Text | Integer -> (Any -> Vector Any) -> | Nothing -> Problem_Behavior -> Table | Nothing
""");
assertSingleSyntaxError(ir, IR$Error$Syntax$UnexpectedExpression$.MODULE$, "Unexpected expression", 48, 119);
}
@Test
public void malformedImport11() throws Exception {
var ir = parse("from import all");