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

BigDecimal_variable % Numeric_value operation causes a compilation error in executable model.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • executable model
    • 2020 Week 52-03 (from Dec 21)
    • Hide
      • Extract reproducer.
        $ unzip reproducer_mc_1b.zip
        $ cd reproducer_mc_1b
        
      • Build and execute the rule.
        $ ./run_mvn    # mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_mc_1b ---
        [INFO] Changes detected - recompiling the module!
        [INFO] Compiling 9 source files to /work2/testdir/reproducer_mc_1b/target/classes
        [INFO] -------------------------------------------------------------
        [ERROR] COMPILATION ERROR : 
        [INFO] -------------------------------------------------------------
        [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,133] bad operand types for binary operator '%'
          first type:  java.math.BigDecimal
          second type: int
        [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,324] bad operand types for binary operator '%'
          first type:  java.math.BigDecimal
          second type: int
        [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,516] bad operand types for binary operator '%'
          first type:  java.math.BigDecimal
          second type: int
        [INFO] 3 errors 
        [INFO] -------------------------------------------------------------
            :
            :
        
      Show
      Extract reproducer. $ unzip reproducer_mc_1b.zip $ cd reproducer_mc_1b Build and execute the rule. $ ./run_mvn # mvn clean compile exec:exec -DgenerateModel=YES : : [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_mc_1b --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 9 source files to /work2/testdir/reproducer_mc_1b/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,133] bad operand types for binary operator '%' first type: java.math.BigDecimal second type: int [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,324] bad operand types for binary operator '%' first type: java.math.BigDecimal second type: int [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,516] bad operand types for binary operator '%' first type: java.math.BigDecimal second type: int [INFO] 3 errors [INFO] ------------------------------------------------------------- : :
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

      Building a rule written in MVEL dialect like (*1) using BigDecimal_variable % Numeric_value operation (*1-1) in executable rule model, a compilation error (*2) occurs.

      (*1)

      package com.example.reproducer
      
      import com.example.reproducer.Fact
      
      dialect "mvel"
      
      rule "rule1b"
          when
              $fact : Fact( $year : year, (($year % 400) == 0) || ((($year % 4) == 0) && (($year % 100) != 0)), $flag : "YES" )    // ..... (*1-1)
          then
              modify($fact) {
                  leapYear = $flag
              }
              System.out.println("***** $fact: " + $fact + ", " + $year + " is a leap year? " + $fact.leapYear);
      end
      

      (*2)

      [ERROR] /work2/testdir/reproducer_mc_1b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PF6/LambdaPredicateF6282A65CE56BF77478DD6D1D7E1AFE4.java:[17,133] bad operand types for binary operator '%'
        first type:  java.math.BigDecimal
        second type: int
      

            lmolteni@redhat.com Luca Molteni
            lmolteni@redhat.com Luca Molteni
            Daniel Rosa Daniel Rosa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: