fix: Data::SExpression jcpan, regex cache pos, short-circuit list context#742
Merged
Conversation
- Invalidate pos() when assigning from another SV so reused hash slots reset (YYData INPUT + lexer \\G); preserve pos for self-assign ($x = $x). - Only arm regex.matched for real m?PAT?; detect match-once via trailing '?' on modifiers, not any '?' (avoids (?:...) false positives). - Materialize short-string literals per occurrence (byte + UTF-8) so scalar identity matches Perl SVs and pos state is not shared incorrectly. - JVM: list-context && / || / // evaluate RHS in LIST context per perlop; bytecode path documents same rule (RHS uses caller context). Generated with [Cursor](https://cursor.com/docs) Co-Authored-By: Cursor <noreply@cursor.com> Co-authored-by: Cursor <cursoragent@cursor.com>
35ff3b7 to
cd27270
Compare
Removing the cache entry orphaned PosLvalueScalar handles that
matchRegexDirect already holds, breaking /g and \G after mid-match
assignments (e.g. (?{ })). Reset the cached position lvalue in place,
refresh valueHash after the new payload is stored, and call
invalidatePos only after set() copies the RHS.
Generated with [Cursor](https://cursor.com/docs)
Co-Authored-By: Cursor <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.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.
Summary
./jcpan -t Data::SExpression(secondread()on the same parser instance failed becauseYYData->{INPUT}reuses oneRuntimeScalarper key; assigning a new string must clearpos()unless it is a true self-assign).m?PAT?handling: only set shared cached regexmatchedfor real match-once patterns; detect match-once via a trailing?on modifiers (notmodifiers.contains("?"), which mis-fires on(?:…)and similar).pos()/ scalar identity behave closer to Perl.&&/||///list-context lowering on the JVM withperlop(RHS uses the operator’s context; LHS stays scalar for the test).Test plan
maketimeout 600 ./jcpan -t Data::SExpression