Rikkola opened a new issue, #7311:
URL: https://github.com/apache/incubator-kie/issues/7311
### Describe the bug
A rule consequence that indexes into the result of a method call and then
calls a method on the element fails to compile on the executable model.
Compilation throws IllegalStateException instead of producing a build result or
running the rule. The non-executable-model build handles the same DRL correctly.
To reproduce add to `EnumTest`:
```
@@ -105,6 +105,35 @@ public class EnumTest {
ksession.dispose();
}
+ @ParameterizedTest(name = "KieBase type={0}")
+ @MethodSource("parameters")
+ public void testIndexedEnumValuesInConsequence(KieBaseTestConfiguration
kieBaseTestConfiguration) {
+ // Not caused by the declared-enum literal count: a plain indexed
+ // values()[n].name() call in a consequence must behave like Java.
+ final String drl =
+ "package org.test;\n" +
+ "global java.util.List list;\n" +
+ "declare enum Color\n" +
+ " RED, GREEN, BLUE;\n" +
+ "end\n" +
+ "rule R when\n" +
+ "then\n" +
+ " list.add( Color.values()[1].name() );\n" +
+ "end\n";
+
+ KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test",
kieBaseTestConfiguration, drl);
+ KieSession ksession = kbase.newKieSession();
+ final List<Object> list = new ArrayList<>();
+ ksession.setGlobal("list", list);
+
+ ksession.fireAllRules();
+
+ assertThat(list)
+ .as("values()[1].name() must evaluate like Java, on every
KieBase configuration")
+ .containsExactly("GREEN");
+ ksession.dispose();
+ }
+
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void
testCrossEnumReferenceWithMisspelledConstant(KieBaseTestConfiguration
kieBaseTestConfiguration) {
```
### Expected behavior
_No response_
### Actual behavior
_No response_
### How to Reproduce?
_No response_
### Output of `uname -a` or `ver`
_No response_
### Output of `java -version`
_No response_
### GraalVM version (if different from Java)
_No response_
### Kogito version or git rev (or at least Quarkus version if you are using
Kogito via Quarkus platform BOM)
_No response_
### Build tool (ie. output of `mvnw --version` or `gradlew --version`)
_No response_
### Additional information
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]