-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[new-parser] rule super_key failed predicate #5703
Comments
@tkobayas I'm taking this one. |
yurloc
added a commit
to yurloc/drools
that referenced
this issue
Feb 27, 2024
This is how one of the `selector` subrules looks like in the old parser: (DOT super_key)=>DOT { helper.emit($DOT, DroolsEditorType.SYMBOL); } super_key superSuffix The whole rule is guarded by a syntactic predicate that is used to make the decision whether this alternative is viable. Syntactic predicates were removed in ANTLR 4 so this subrule became: DOT { helper.emit($DOT, DroolsEditorType.SYMBOL); } super_key superSuffix The failing predicate is "hidden" inside the `super_key` rule but it actually cannot be used to make the decision because it is now "invisible". See https://github.com/antlr/antlr4/blob/master/doc/predicates.md#finding-visible-predicates that explains how predicates can become invisible. The thing that makes the predicate invisible here is the action after `DOT`. And since the alternative is now unguarded it seems viable and so it is taken and the `super_key` rule is evaluated. At this point, inside `super_key` there is only a single alternative. It is guarded by a predicate that evaluates to `false`, which is an error condition. The fix is to restore the guard in front of this `selector` alternative that prevents taking should the super key predicate later turn out to be false. Fixes apache#5703.
yurloc
added a commit
to yurloc/drools
that referenced
this issue
Feb 27, 2024
This is how one of the `selector` subrules looks like in the old parser: (DOT super_key)=>DOT { helper.emit($DOT, DroolsEditorType.SYMBOL); } super_key superSuffix The whole rule is guarded by a syntactic predicate that is used to make the decision whether this alternative is viable. Syntactic predicates were removed in ANTLR 4 so this subrule became: DOT { helper.emit($DOT, DroolsEditorType.SYMBOL); } super_key superSuffix The failing predicate is "hidden" inside the `super_key` rule but it actually cannot be used to make the decision because it is now "invisible". See https://github.com/antlr/antlr4/blob/master/doc/predicates.md#finding-visible-predicates that explains how predicates can become invisible. The thing that makes the predicate invisible here is the action after `DOT`. And since the alternative is now unguarded it seems viable and so it is taken and the `super_key` rule is evaluated. At this point, inside `super_key` there is only a single alternative. It is guarded by a predicate that evaluates to `false`, which is an error condition. The fix is to restore the guard in front of this `selector` alternative that prevents taking should the super key predicate later turn out to be false. Fixes apache#5703.
github-project-automation
bot
moved this from 📋 Backlog
to 🎯 Done
in 🦉 KIE Podling Board
Mar 4, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parent issue
Failing tests
org.drools.model.codegen.execmodel.NodeSharingTest#testShareAccumulate
Notes
STANDARD_FROM_DRL
only.Rule code snippet
Error output
The text was updated successfully, but these errors were encountered: