Treat ^ and v as operators even without surrounding whitespace#639
Open
chuenchen309 wants to merge 1 commit into
Open
Treat ^ and v as operators even without surrounding whitespace#639chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
parse_boolean_expr has a fast-path that returns the whole string as a single variable name when it contains no operator. It only checked for "!", not the other two classical operators "^" (and) and "v" (or), so an unspaced guard like cond="a^b" skipped operator replacement and was looked up as a variable named "a^b" -- silently evaluating wrong (or raising InvalidDefinition on a StateChart). "!a" already worked unspaced, so this was an inconsistency. Gate the fast-path on the module's existing operator `pattern` (which already matches !, ^ and the word-bounded v) instead of a hand-rolled "!" check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: chuenchen309 <48723787+chuenchen309@users.noreply.github.com>
|
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.



parse_boolean_exprhas a fast-path that returns the whole expression as asingle variable name when it looks operator-free. It only checked for
!, notthe other two documented classical operators
^(and) /v(or), so anunspaced guard skipped operator replacement and was resolved as a variable:
a^bthen evaluates wrong (or raisesInvalidDefinition: Did not found name 'a^b'at class-definition time). Since!aalready worked without spaces, theinconsistency is surprising — users copy operators from the guards docs, where
^/vare listed with no whitespace requirement.Gate the fast-path on the module's existing
pattern(which already matches!,^, and the word-boundedv) instead of the hand-rolled"!" not in exprcheck. Genuine single-name variables like
avc(no word-boundaryv) stilltake the fast-path. Added a regression test asserting the unspaced forms match
their spaced equivalents.
This PR was authored by an AI coding agent (Claude Code) running on this account:
the AI found the bug, ran the repro, wrote the test, and wrote this description.
The human account holder reviews every change and is accountable for it. The
verification is real and re-runnable from the diff. If this isn't the kind of
contribution you want, say so and I'll close it.