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

Type coercion does not work for bound variables in executable model.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • executable model
    • 2020 Week 52-03 (from Dec 21)
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_15a.zip
        $ cd reproducer_model_compiler_15a
        
      2. Build and execute the rule.
        $ ./run_mvn    # mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        ***** start
        ***** Action of rule15a1 -- $items = 3
        ***** end
            :
            :
        

      Expected behavior: the action part of the rule is not executed.

      Actual behavior: the action part of the rule is executed.

      Show
      Extract reproducer. $ unzip reproducer_model_compiler_15a.zip $ cd reproducer_model_compiler_15a Build and execute the rule. $ ./run_mvn # mvn clean compile exec:exec -DgenerateModel=YES : : ***** start ***** Action of rule15a1 -- $items = 3 ***** end : : Expected behavior: the action part of the rule is not executed. Actual behavior: the action part of the rule is executed.
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

      When executing a rule like (*1) that uses comparison between different-type bound variables (for example, an Integer variable and a String variable consisting of digit characters like (*1-1)), the action part of the rule is unexpectedly fired in executable model though the result of the comparison is expected to be false.

      (*1)

      package com.example.reproducer
      
      import static com.example.reproducer.CommonUtils.getListSize
      
      dialect "java"
      
      rule "rule15a1"
          when
              Order( $target : "3",
                     $items : getListSize(items),
                     $items != $target )           // ..... (*1-1)
          then
              System.out.println("***** Action of rule15a1 -- $items = " + $items);
      end
      

              mfusco@redhat.com Mario Fusco
              mfusco@redhat.com Mario Fusco
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: