[jboss-jira] [JBoss JIRA] (DROOLS-5216) Rule compilation error when binding fields indexed with square brackets

Matteo Casalino (Jira) issues at jboss.org
Fri Apr 3 09:17:15 EDT 2020


Matteo Casalino created DROOLS-5216:
---------------------------------------

             Summary: Rule compilation error when binding fields indexed with square brackets
                 Key: DROOLS-5216
                 URL: https://issues.redhat.com/browse/DROOLS-5216
             Project: Drools
          Issue Type: Bug
          Components: core engine
    Affects Versions: 7.35.0.Final
            Reporter: Matteo Casalino
            Assignee: Mario Fusco
         Attachments: binding-field-indexed-with-square-brackets.zip

Executable model rule compilation fails on patters that bind a collection field indexed with square brackets

Example of DRL that fails to compile:

{noformat}
    rule "binding field indexed with square brackets"
    when Pojo($firstItem : integerList[0])
         Pojo(integerList[this.integerList.size()-1] == $firstItem)
    then
    end
{noformat}

Error:

{noformat}
    Message [id=1, level=ERROR, path=src/main/java/org/drools/reproducer/RulesE96881902F91EBF30C7D6404720A1A94RuleMethods0.java, line=29, column=138
       text=no suitable method found for bind(org.drools.model.Variable<java.util.Map>,(org.drool[...]et(0))
        method org.drools.model.PatternDSL.PatternDef.<A>bind(org.drools.model.Variable<A>,org.drools.model.functions.Function1<org.drools.reproducer.Pojo,A>) is not applicable
          (inference variable A has incompatible bounds
            equality constraints: java.util.Map
            lower bounds: java.lang.Integer)
        method org.drools.model.PatternDSL.PatternDef.<A>bind(org.drools.model.Variable<A>,org.drools.model.functions.Function1<org.drools.reproducer.Pojo,A>,org.drools.model.PatternDSL.ReactOn) is not applicable
          (cannot infer type-variable(s) A
            (actual and formal argument lists differ in length))
        method org.drools.model.PatternDSL.PatternDef.<A,U>bind(org.drools.model.Variable<A>,org.drools.model.Variable<U>,org.drools.model.functions.Function1<U,A>) is not applicable
          (cannot infer type-variable(s) A,U
            (actual and formal argument lists differ in length))
{noformat}

The example works fine when compiling without executable model.

Furthermore, the same example expressed with OOPath fails to compile *both with and without executable model*:

{noformat}
    rule "binding field indexed with square brackets in OOPath"
    when Pojo($firstItem : /integerList[0])
    Pojo(/integerList[this.integerList.size()-1] == $firstItem)
    then
    end
{noformat}

Error without executable model:

{noformat}
    Message [id=1, kieBase=binding-field-indexed-with-square-brackets, level=ERROR, path=org/drools/reproducer/rules.drl, line=4, column=0
       text=Unable to Analyse Expression /integerList[this.integerList.size()-1] == $firstItem:
    [Error: Missing left node]
    [Near : {... /integerList[this.integerList.size()-1] == $firstItem ....}]
{noformat}

Error with executable model:

{noformat}
    Message [id=1, kieBase=binding-field-indexed-with-square-brackets, level=ERROR, path=org/drools/reproducer/rules.drl, line=-1, column=0
       text=Unknown field integerList on class java.lang.Integer]
{noformat}



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list