[jboss-jira] [JBoss JIRA] (DROOLS-1420) (int) ($p * 1_000.0) throws a misleading exception

Geoffrey De Smet (JIRA) issues at jboss.org
Fri Jan 27 10:31:00 EST 2017


Geoffrey De Smet created DROOLS-1420:
----------------------------------------

             Summary: (int) ($p * 1_000.0) throws a misleading exception
                 Key: DROOLS-1420
                 URL: https://issues.jboss.org/browse/DROOLS-1420
             Project: Drools
          Issue Type: Bug
          Components: core engine
    Affects Versions: 7.0.0.Beta5
            Reporter: Geoffrey De Smet
            Assignee: Mario Fusco


This fails with *$p cannot be resolved to a variable*:
{code}
rule R when
  Cheese($p : price)
then
  int b = (int) ($p * 1_000.0); // FAILS, because $p cannot be resolved ?!
end
{code}

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:
{code}
        int a = 42;
        int b = ((int) (a * 1_000.0));
{code}

Removing the underscore fixes it:

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

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.




--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list