Skip to content

Commit

Permalink
Merge pull request #2111 from lf-lang/types
Browse files Browse the repository at this point in the history
Type check error turned into warning
  • Loading branch information
lhstrh authored Dec 9, 2023
2 parents 2cb9b33 + f5101ee commit f6ef5dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/lflang/validation/LFValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void checkConnection(Connection connection) {
} else {
var portType = portTypeIfResolvable(port);
if (!sameType(type, portType)) {
error("Types do not match.", Literals.CONNECTION__LEFT_PORTS);
warning("Multiple types in connection statement.", Literals.CONNECTION__ITERATED);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,36 @@ public void disallowUnderscoreActions() throws Exception {
+ " definitions, and reactor instantiation) may not start with \"__\": __bar");
}

/** Warn against using multiple types in connection statement. */
@Test
public void warnAgainstMultipleTypes() throws Exception {
String testCase =
"""
target C
reactor A {
output request:int
input response:float
}
reactor B {
input request:int
output response:float
}
main reactor {
a1 = new A();
a2 = new A();
b1 = new B();
b2 = new B();
a1.request, b1.response -> b1.request, a1.response
a2.request, b2.response -> b2.request, a2.response
}
""";
validator.assertWarning(
parseWithoutError(testCase), LfPackage.eINSTANCE.getConnection(), null, "multiple types");
}

/** Ensure that "__" is not allowed at the start of a timer name. */
@Test
public void disallowUnderscoreTimers() throws Exception {
Expand Down

0 comments on commit f6ef5dc

Please sign in to comment.