]
Luca Molteni updated DROOLS-5548:
---------------------------------
Summary: Model compiler cannot generate declaration from a function call (was: Model
compiler cannot generate code for method calls using variable accessors)
Model compiler cannot generate declaration from a function call
---------------------------------------------------------------
Key: DROOLS-5548
URL:
https://issues.redhat.com/browse/DROOLS-5548
Project: Drools
Issue Type: Bug
Components: executable model
Affects Versions: 7.31.0.Final, 7.32.0.Final, 7.33.0.Final, 7.34.0.Final,
7.35.0.Final, 7.36.0.Final, 7.37.0.Final, 7.38.0.Final, 7.39.0.Final, 7.40.0.Final
Reporter: Ciprian Chiru
Assignee: Luca Molteni
Priority: Major
Given the example rule below (based on the drools example rule)
{code:java}
global java.util.Set controlSet;
declare A
x: String
end
declare B
a: A
end
function String dummyFunction(B b) {
return "test";
}
rule "will execute per each Measurement having ID color"
no-loop
when
Measurement( id == "color", $colorVal : val )
$b: B()
$val: String() from dummyFunction($b.a)
then
controlSet.add($colorVal);
end{code}
When compiling the rule with _kie-maven-plugin_ it fails with :
{noformat}
...target/generated-sources/drools-model-compiler/main/java/rules/Rules5937a2896da74f01bfa36d294bcf0858RuleMethods0.java:[32,107]
cannot find symbol
[ERROR] symbol: variable $b
[ERROR] location: class
rules.Rules5937a2896da74f01bfa36d294bcf0858RuleMethods0{noformat}
It transpiles and compiles fine with:
{code:java}
$val: String() from dummyFunction($b){code}
This can probably be reproduced on all version.
It works when the rules are not pre-compiled.