You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "yurloc (via GitHub)" <gi...@apache.org> on 2024/05/06 08:32:13 UTC
[I] [new-parser] `drools-verifier` fails to remove comments from RHS consequence [incubator-kie-drools]
yurloc opened a new issue, #5886:
URL: https://github.com/apache/incubator-kie-drools/issues/5886
## Parent issue
- #5678
## Failing tests
- `org.drools.verifier.*`
## Notes
This is, in my opinion, a minor bug in `drools-verifier` that manifests due to a slight change of behavior in the new parser.
The Verifier at some point cleans the RHS code by removing comments. While doing that, it assumes that each comment line (`// asdf...`) ends with a new-line character. This is no longer true with the new parser if the comment is the last line before the RHS end or before another named consequence (`then[label]`). This is simply because the whitespace part of the input between the default RHS consequence and any named consequence(s) or RHS end is not part of the consequence RuleContext. This is natural to how the ANTLR parser works.
The old parser's behavior could be replicated with some custom code but in this case, I think it's better to align with the new behavior and adapt the Verifier code to it.
## Rule code snippet
```
rule "Missing equality 1"
when
MissingEqualityPattern1( value == 10 )
then
//actions
end
```
## Error output
```
### parse : ANTLR4_PARSER_ENABLED = true
### parse : ANTLR4_PARSER_ENABLED = true
java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 9
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
at java.base/java.lang.AbstractStringBuilder.delete(AbstractStringBuilder.java:904)
at java.base/java.lang.StringBuilder.delete(StringBuilder.java:289)
at org.drools.verifier.visitor.RuleDescrVisitor.visitConsequence(RuleDescrVisitor.java:206)
at org.drools.verifier.visitor.RuleDescrVisitor.visitRuleDescr(RuleDescrVisitor.java:70)
at org.drools.verifier.visitor.PackageDescrVisitor.visitRuleDescr(PackageDescrVisitor.java:120)
at org.drools.verifier.visitor.PackageDescrVisitor.visitRules(PackageDescrVisitor.java:113)
at org.drools.verifier.visitor.PackageDescrVisitor.visitPackageDescr(PackageDescrVisitor.java:65)
at org.drools.verifier.TestBaseOld.getTestData(TestBaseOld.java:124)
at org.drools.verifier.missingEquality.MissingEqualityTest.testMissingEqualityInLiteralRestrictions(MissingEqualityTest.java:50)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [I] [new-parser] `drools-verifier` fails to remove comments from RHS consequence [incubator-kie-drools]
Posted by "yurloc (via GitHub)" <gi...@apache.org>.
yurloc closed issue #5886: [new-parser] `drools-verifier` fails to remove comments from RHS consequence
URL: https://github.com/apache/incubator-kie-drools/issues/5886
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [I] [new-parser] `drools-verifier` fails to remove comments from RHS consequence [incubator-kie-drools]
Posted by "yurloc (via GitHub)" <gi...@apache.org>.
yurloc commented on issue #5886:
URL: https://github.com/apache/incubator-kie-drools/issues/5886#issuecomment-2095453174
`/take`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org