Skip to content

Commit 66e6eaa

Browse files
committed
[#755] Improve error handling for missing variable declaration
1 parent f61c0c2 commit 66e6eaa

File tree

7 files changed

+1895
-13
lines changed

7 files changed

+1895
-13
lines changed

dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/FEELSemanticVisitor.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,24 +1045,28 @@ public Element<Type> visit(Name<Type> element, DMNContext context) {
10451045
}
10461046

10471047
private void deriveType(NamedExpression<Type> element, DMNContext context, String name) {
1048-
Type type;
10491048
// Lookup for variables
10501049
Declaration declaration = context.lookupVariableDeclaration(name);
10511050
if (declaration instanceof VariableDeclaration) {
1052-
type = declaration.getType();
1051+
Type type = declaration.getType();
10531052
element.setType(type);
1054-
} else {
1055-
// Lookup for functions
1056-
List<Declaration> declarations = context.lookupFunctionDeclaration(name);
1057-
if (declarations != null && !declarations.isEmpty()) {
1058-
if (declarations.size() == 1) {
1059-
declaration = declarations.get(0);
1060-
type = declaration.getType();
1061-
} else {
1062-
type = new BuiltinOverloadedFunctionType(declarations);
1063-
}
1064-
element.setType(type);
1053+
return;
1054+
}
1055+
// Lookup for functions
1056+
List<Declaration> declarations = context.lookupFunctionDeclaration(name);
1057+
if (declarations != null && !declarations.isEmpty()) {
1058+
Type type;
1059+
if (declarations.size() == 1) {
1060+
declaration = declarations.get(0);
1061+
type = declaration.getType();
1062+
} else {
1063+
type = new BuiltinOverloadedFunctionType(declarations);
10651064
}
1065+
element.setType(type);
1066+
return;
1067+
}
1068+
if (this.dmnTransformer.isStrongTyping()) {
1069+
errorHandler.reportError(String.format("Cannot find declaration for '%s'", name));
10661070
}
10671071
}
10681072

dmn-core/src/test/java/com/gs/dmn/runtime/interpreter/AbstractCL3DMNInterpreterTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,11 @@ public void test_15_cl3_0068_feel_equality() {
622622
doFolderTest("1.5", "0068-feel-equality", new Pair<>("strongTyping", "false") );
623623
}
624624

625+
@Test
626+
public void test_15_cl3_0069_feel_list() {
627+
doFolderTest("1.5", "0069-feel-list", new Pair<>("strongTyping", "false") );
628+
}
629+
625630
@Test
626631
public void test_15_cl3_0072_feel_in() {
627632
doFolderTest("1.5", "0072-feel-in", new Pair<>("strongTyping", "false") );

0 commit comments

Comments
 (0)