BugFix: Reference counting for comma-separated rung instruction arguments#79
Open
johnpuksta wants to merge 2 commits into
Open
BugFix: Reference counting for comma-separated rung instruction arguments#79johnpuksta wants to merge 2 commits into
johnpuksta wants to merge 2 commits into
Conversation
…pe.Of to handle leading whitespace bug preventing proper referencing of multiple items in rungs
johnpuksta
force-pushed
the
fix/reference-counting-in-rungs
branch
from
July 8, 2026 03:19
e02a623 to
7a44277
Compare
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.
Problem
When a rung contains instructions with multiple comma-separated arguments (e.g.,
MOV(Source, Dest)orTON(Timer, Preset, Accum)), only the first argument is recognized as a tag reference. Arguments after commas are silently dropped.Root Cause
Instruction.ParseArguments()splits instruction text by comma but doesn't trim whitespace from the results. ForMOV(Source, Dest), the split produces["Source", " Dest"]. The leading space on" Dest"causesTagName.IsTag()to fail (the base name regex^[A-Za-z_][\w:]{0,39}$rejects leading spaces), so the argument is classified asUnknowninstead ofReference.Fix
Instruction.ParseArguments(): Add.Trim()to comma-split argument resultsArgumentType.Of(): Trim before type classification (defensive, for direct callers)Tests Added
RungTests: Parameterized tests for multi-arg instructions, duplicate tags across instructions, and branch scenariosArgumentTests: Leading whitespace toleranceArgumentTypeTests: Leading whitespace toleranceTagNameTests:IsTag()behavior with whitespace (enforces that trimming is not it's responsibility)InstructionTests: Comma-separated args with whitespaceL5XReferencesTests: End-to-end reference counting for same tag in different instructions and same instruction