Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5216

Rule compilation error when binding fields indexed with square brackets

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • 7.35.0.Final
    • core engine
    • None
    • 2020 Week 13-15 (from Mar 23)
    • Hide

      run

      mvn clean test
      

      on attached reproducer.

      Show
      run mvn clean test on attached reproducer.
    • NEW
    • NEW

    Description

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

      Example of DRL that fails to compile:

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

      Error:

          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))
      

      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:

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

      Error without executable model:

          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 ....}]
      

      Error with executable model:

          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]
      

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            mcasalino Matteo Casalino (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: