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

Compilation error with block lambda expression in RHS with non-exec-model

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 7.71.0.Final
    • core engine
    • None
    • 2022 Week 26-28 (from Jun 27), 2022 Week 29-31 (from Jul 18), 2022 Week 41-43 (from Oct 10)
    • Workaround Exists
    • Hide

      A) Use executable-model
      B) Use a java static method to encapsulate the lambda (= hide lambda from RHS)

      Show
      A) Use executable-model B) Use a java static method to encapsulate the lambda (= hide lambda from RHS)
    • NEW
    • NEW
    • ---
    • ---

    Description

      Rule like this:

      rule Hello1
        when
          $list : List()
          $p : Person()
        then
          $list.stream().forEach((i) -> {System.out.println("Here");});
          modify($p) {
              setAge(100);
          };
      end
      

      throws a compilation error:

      Rule Compilation error : [Rule name='Hello1']
      	$p cannot be resolved to a variable
      	Syntax error, insert ";" to complete Statement
      	The method setAge(int) is undefined for the type Rule_Hello1952063464
      

      with non-exec-model.

      On the other hand, Lambda without a block works:

      $list.stream().forEach(i ->  System.out.println("Here"));
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: