From caf1c0a110aec1f29803bb4e9a0f3fdc26b98e79 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Tue, 25 Apr 2023 14:56:02 +0200 Subject: [PATCH] Turn null into UnexpectedExpression when Union type is incomplete --- .../runtime/src/main/java/org/enso/compiler/TreeToIr.java | 3 +++ .../test/java/org/enso/compiler/ErrorCompilerTest.java | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/engine/runtime/src/main/java/org/enso/compiler/TreeToIr.java b/engine/runtime/src/main/java/org/enso/compiler/TreeToIr.java index 13141b665bb6..67d7df1bd3ea 100644 --- a/engine/runtime/src/main/java/org/enso/compiler/TreeToIr.java +++ b/engine/runtime/src/main/java/org/enso/compiler/TreeToIr.java @@ -1084,6 +1084,9 @@ IR.Expression translateType(Tree tree, boolean insideTypeAscription) { } 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 loc = getIdentifiedLocation(tree); diff --git a/engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java b/engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java index 4ea080cf5577..1d7172849ba6 100644 --- a/engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java +++ b/engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java @@ -192,6 +192,14 @@ public void malformedImport10() throws Exception { 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");