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

Unknown variable: $object in foreach loop

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.60.0.Final
    • 7.54.0.Final
    • Impact Analysis
    • None
    • 2021 Week 25-27 (from Jun 21), 2021 Week 34-36 (from Aug 23), 2021 Week 37-39 (from Sep 13)
    • 2
    • Undefined
    • NEW
    • NEW

      When parsing a rule:

      rule R1
        when
          $objectList : List() from collect(Object())
        then
          for(Object $object : $objectList){
            delete($object);
          }
      end
      

      throws an Exception:

      Exception in thread "main" java.lang.RuntimeException: Unknown variable: $object
      	at org.drools.impact.analysis.parser.impl.RhsParser.lambda$getClassNameFromCreation$11(RhsParser.java:116)
      	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
      	at org.drools.impact.analysis.parser.impl.RhsParser.getClassNameFromCreation(RhsParser.java:116)
      	at org.drools.impact.analysis.parser.impl.RhsParser.lambda$getClassFromAssignment$5(RhsParser.java:93)
      	at java.base/java.util.Optional.orElseGet(Optional.java:369)
      	at org.drools.impact.analysis.parser.impl.RhsParser.getClassFromAssignment(RhsParser.java:93)
      	at org.drools.impact.analysis.parser.impl.RhsParser.lambda$processAction$4(RhsParser.java:78)
      	at java.base/java.util.Optional.orElseGet(Optional.java:369)
      	at org.drools.impact.analysis.parser.impl.RhsParser.processAction(RhsParser.java:78)
      	at org.drools.impact.analysis.parser.impl.RhsParser.processStatement(RhsParser.java:70)
      	at org.drools.impact.analysis.parser.impl.RhsParser.lambda$parse$2(RhsParser.java:57)
      	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
      	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
      	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
      	at org.drools.impact.analysis.parser.impl.RhsParser.parse(RhsParser.java:59)
      	at org.drools.impact.analysis.parser.impl.PackageParser.parseRule(PackageParser.java:63)
      	at org.drools.impact.analysis.parser.impl.PackageParser.parse(PackageParser.java:50)
      

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: