The use of AND in source pattern of accumulate causes compilation error in executable model.

Solution Unverified - Updated -

Issue

Building a rule written in MVEL dialect like (*1) using AND in source pattern of accumulate like (*1-1) in executable rule model, a compilation error (*2) occurs.

(*1) rule

package com.example.reproducer

import java.math.BigDecimal

dialect "mvel"

rule "rule7a2"
    when
        $total : BigDecimal() from accumulate( $car : Car( discontinued == true ) and Order( item == $car, $price : price ), // ..... (*1-1)
                                               init( BigDecimal total = BigDecimal.ZERO; ),
                                               action( total += $price; ),
                                               reverse( total -= $price; ),
                                               result( total ) )
    then
        System.out.println("***** Action of rule7a2 -- $total = " + $total);
end

(*2)

$ mvn clean compile exec:exec -DgenerateModel=YES
...
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_7a ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 13 source files to /work2/testdir/reproducer_model_compiler_7a/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /work2/testdir/reproducer_model_compiler_7a/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/Rulese69ee9f6a2a84acaa675792cae099156RuleMethods0.java:[28,63] method accumulate in class org.drools.model.DSL cannot be applied to given types;
  required: org.drools.model.view.ViewItem<?>,org.drools.model.functions.accumulate.AccumulateFunction,org.drools.model.functions.accumulate.AccumulateFunction[]
  found: org.drools.model.view.ViewItem
  reason: cannot infer type-variable(s) T
    (actual and formal argument lists differ in length)
[INFO] 1 error
[INFO] -------------------------------------------------------------
...

This issue does not occur when we build the rule with executable model disabled.

Environment

  • Red Hat Decision Manager (RHDM)
    • 7.1.0 - 7.10.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content