This is an ambiguity inherent to the DRL language. This happens because
the parser has no way of knowing if the (...) following the expression
belong to the expression (i.e., is a method call, where you forgot the ","
between parameters) or if it is not part of the expression. So, we
arbitrarily decided that the parser will always consider the () in this case
as part of the expression, and if it is not a valid syntax, it will raise an
error. You found one way of breaking the ambiguity by adding () on
getAddresses, but you could also do:
( Address( ) from $person.addresses )
or add a ; at the end of the expression:
Address( ) from $person.addresses;
It is not a bug, as it is an ambiguity inherent to the language, not the
implementation, but I guess we could have better documentation on that. Just
for the curious, it is the same kind of ambiguity present on java/c++
parsers when you have nested "if/else" without blocks {}. Ex:
if (...)
if( ... )
...;
else
...;
Does the else above belong to the first or second "if"? The parser has
no way to know that, so they arbitrarily decided that in java/c++ that says
the else belongs to the closest "if" and my identation above is
misleading...
Edson
2011/1/26 Evert Penninckx <evert.penninckx(a)gmail.com>
Hi
This little rule won't compile:
rule "Test from and or"
dialect "mvel"
when
$person : Person()
Address( ) from $person.addresses
(Address() or Address())
then
# do stuff
end
BuildError: Unable to build expression for 'from' : [Error: Failed to
compile: 1 compilation error(s):
- (1,7) unqualified type in strict mode for: $person]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0] '$person.addresses(Address() or Address())'
BuildError: Unable to determine the used declarations.
java.lang.Class cannot be cast to org.mvel2.util.MethodStub
This does work
rule "Test from and or"
dialect "mvel"
when
$person : Person()
Address( ) from $person.addresses
Address() or Address()
then
# do stuff
end
And this also:
rule "Test from and or"
dialect "mvel"
when
$person : Person()
Address( ) from $person.getAddresses()
(Address() or Address())
then
# do stuff
end
Can anybody confirm this as a bug?
Tnx
Evert
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Possible-bug-using-fr...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com