fix: prevent duplicate party assignment in assign_implicit_party#728
Merged
Conversation
Add check to skip assigning implicit party when the rule definition already contains party definitions. This prevents overwriting existing party assignments in grammar rules.
|
| Branch | fix/assign-implicit-party |
| Testbed | ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| tests/test_benchmarks.py::test_generate_with_single_hard_constraint | 📈 view plot 🚷 view threshold | 1,801.65 ms(-3.12%)Baseline: 1,859.71 ms | 2,139.78 ms (84.20%) |
| tests/test_benchmarks.py::test_generate_with_single_soft_constraint | 📈 view plot 🚷 view threshold | 51,153.52 ms(-3.33%)Baseline: 52,914.16 ms | 79,972.04 ms (63.96%) |
| tests/test_benchmarks.py::test_init_fandango | 📈 view plot 🚷 view threshold | 119.15 ms(-21.40%)Baseline: 151.58 ms | 161.89 ms (73.60%) |
| tests/test_benchmarks.py::test_parse_spec | 📈 view plot 🚷 view threshold | 119.85 ms(-21.76%)Baseline: 153.17 ms | 160.36 ms (74.74%) |
# Conflicts: # src/fandango/language/parse.py
alex9849
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For example, in
smtp-telnet.fan:When a non-terminal symbol (e.g.,
<smtp>) in a grammar rule lacks explicit party annotations, theassign_implicit_partyfunction automatically assigns the defaultStdOutparty to it. However, this can cause nested party issues when the rule definition already contains party definitions in its child nodes.The
<smtp>non-terminal itself has no party annotation, but its children (<Out:m220>,<In:quit>,<Out:m221>) already have explicit party definitions. Without this fix,<smtp>would be assignedStdOut, creating an illegal nested party structure.Solution
Added a check in
assign_implicit_partyto skip assigning an implicit party when the rule definition of a non-terminal already contains party definitions. This prevents overwriting existing party assignments and avoids nested party errors.