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

Compilation error for "from accumulate" init() with executable-model or not

    Details

    • Sprint:
      2019 Week 29-31, 2019 Week 32-34
    • Story Points:
      3
    • Steps to Reproduce:
      Hide
      • Build the DRL with/without -DgenerateModel=YES
        import org.drools.modelcompiler.domain.Person;
        rule R when
          $sum : Integer() from accumulate (
                    Person( age > 18, $age : age ),
                        init( int sum = 0 ),
                        action( sum += $age; ),
                        reverse( sum -= $age; ),
                        result( sum )
                 )
        then
          insert($sum);
        end
        
      Show
      Build the DRL with/without -DgenerateModel=YES import org.drools.modelcompiler.domain.Person; rule R when $sum : Integer() from accumulate ( Person( age > 18, $age : age ), init( int sum = 0 ), action( sum += $age; ), reverse( sum -= $age; ), result( sum ) ) then insert($sum); end
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      If we miss a semicolon in init() of "from accumulate",

      for example)

      import org.drools.modelcompiler.domain.Person;
      rule R when
        $sum : Integer() from accumulate (
                  Person( age > 18, $age : age ),
                      init( int sum = 0 ),
                      action( sum += $age; ),
                      reverse( sum -= $age; ),
                      result( sum )
               )
      then
        insert($sum);
      end
      
      • Not executable-model -> The DRL is compiled and executed successfully
      • Executable-model -> Throws ParseProblemException
      com.github.javaparser.ParseProblemException: (line 1,col 12) Parse error. Found "}", expected one of  "!=" "%" "%=" "&" "&&" "&=" "*" "*=" "+" "+=" "," "-" "-=" "->" "/" "/=" "::" ";" "<" "<<=" "<=" "=" "==" ">" ">=" ">>=" ">>>=" "?" "^" "^=" "instanceof" "|" "|=" "||"
      Problem stacktrace : 
        com.github.javaparser.GeneratedJavaParser.generateParseException(GeneratedJavaParser.java:10567)
        com.github.javaparser.GeneratedJavaParser.jj_consume_token(GeneratedJavaParser.java:10426)
        com.github.javaparser.GeneratedJavaParser.BlockStatement(GeneratedJavaParser.java:3847)
        com.github.javaparser.GeneratedJavaParser.Statements(GeneratedJavaParser.java:1644)
        com.github.javaparser.GeneratedJavaParser.Block(GeneratedJavaParser.java:3822)
        com.github.javaparser.GeneratedJavaParser.BlockParseStart(GeneratedJavaParser.java:5687)
        com.github.javaparser.JavaParser.parse(JavaParser.java:115)
        com.github.javaparser.JavaParser.parseBlock(JavaParser.java:309)
        com.github.javaparser.StaticJavaParser.parseBlock(StaticJavaParser.java:240)
        org.drools.modelcompiler.builder.generator.visitor.accumulate.AccumulateVisitor.visitAccInlineCustomCode(AccumulateVisitor.java:434)
        ...
      

      I'm not very sure how it should be fixed. I filed this because of discrepancy between Executable-model and Not executable-model

      Poosible choices are:

      • Fail even in case of Not executable-model
      • Success in case of Executable-model

      Additonal Note: If we miss a semicolon in action(), a more understandable error message is thrown.

      [Message [id=1, kieBase=defaultKieBase, level=ERROR, path=r0.drl, line=2, column=0
         text=Rule Compilation error Syntax error, insert ":: IdentifierOrNew" to complete Expression
      Syntax error, insert ";" to complete Statement]]
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  volothamp Luca Molteni
                  Reporter:
                  tkobayashi Toshiya Kobayashi
                  Tester:
                  Daniele Zonca
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: