diff --git a/core/src/main/java/org/lflang/validation/LFValidator.java b/core/src/main/java/org/lflang/validation/LFValidator.java index 7dfa0e557d..e12ab17061 100644 --- a/core/src/main/java/org/lflang/validation/LFValidator.java +++ b/core/src/main/java/org/lflang/validation/LFValidator.java @@ -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); } } } diff --git a/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java b/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java index 0897551b5f..2d95e0ac4a 100644 --- a/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java +++ b/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java @@ -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 {