5.1 and trunk permits you to write e.g.<br><br> Foo( $array: array )<br> Bar( this == $array[0] )<br><br>but this crashes druing compilation with <br> java.lang.StringIndexOutOfBoundsException: String index out of range: -1<br>
at java.lang.String.substring(String.java:1949)<br> at org.drools.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:928)<br><br>It's OK by this syntax:<br> accessor_element ; ID square_chunk* ;<br>
<br>Processing in DescriptorFactory handles []:<br><br>createAccessorPath(List<BaseDescr> aeList) {<br> ...<br>if (name.indexOf('.') > -1 || name.indexOf('[') > -1) {<br> evaluator = new QualifiedIdentifierRestrictionDescr();<br>
<br>Then in PatternBuilder, we end up in this variant of the overloaded method buildRestriction:<br><br> private Restriction buildRestriction(final RuleBuildContext context,<br> final InternalReadAccessor extractor,<br>
final FieldConstraintDescr fieldConstraintDescr,<br> final QualifiedIdentifierRestrictionDescr qiRestrictionDescr) <br><br>and this is where it happens, lastDot being == -1.<br>
<br>{ final int lastDot = qiRestrictionDescr.getText().lastIndexOf( '.' );<br> final String className = qiRestrictionDescr.getText().substring( 0,<br> lastDot );<br>
<br>If the syntax isn't too permissive, then this method would have to handle x[y] in<br>addition to x.y, etc.<br><br>-W<br><br><br>