]
Mario Fusco resolved DROOLS-1420.
---------------------------------
Fix Version/s: 7.0.0.CR1
Resolution: Done
Fixed by
(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
Fix For: 7.0.0.CR1
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.