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

(int) ($p * 1_000.0) throws a misleading exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.0.Beta7
    • 7.0.0.Beta5
    • core engine
    • None
    • NEW
    • NEW

      This fails with $p cannot be resolved to a variable:

      rule R when
        Cheese($p : price)
      then
        int b = (int) ($p * 1_000.0); // FAILS, because $p cannot be resolved ?!
      end
      

      That error message is nonsense. It should just work. If it doesn't due to ECJ, it should say something like "cannot be cast".

      This works in java:

              int a = 42;
              int b = ((int) (a * 1_000.0));
      

      Removing the underscore fixes it:

      rule R when
        Cheese($p : price)
      then
        int b = (int) ($p * 1000.0); // SUCCESS
      end
      

      Regardless of an upstream ECJ problem (which should be reported if that's indeed the problem), the error message is wrong and send me on a wild goose hunt.

              mfusco@redhat.com Mario Fusco
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: