Conversation
Takes ./jcpan -t Tie::File from 336 failures / 16 failing test files to all 4725 tests passing. Six related bugs in tied-array and $. handling: 1. $. numeric reads stale zero after local $. + reads. ScalarSpecialVariable.set() cached this.type=INTEGER, this.value=0 on the proxy. Readline mutates currentLineNumber directly, so the cache goes stale. Numeric comparison fast paths (arg.type==INTEGER -> (int)arg.value) then read 0. Removed the sync; $. always delegates through getValueAsScalar(). 2. $. not incremented for multi-char $/. readUntilString only bumped currentLineNumber on '\n' in the line. Custom separators with no newline left $. at 0. Now increments once per record read, regardless of separator content. 3. Tied push/unshift returned the tie method's raw return value. Perl's av.c ignores the PUSH/UNSHIFT return and reports FETCHSIZE. Tie::File's PUSH returns nothing on purpose. tiedPush/tiedUnshift now call the handler and then return FETCHSIZE. 4. Tied SPLICE always called in scalar context. tieCall hardcoded SCALAR, so @r = splice(@tied, ...) got back the scalar count. Context now flows through Operator.splice and TieArray.tiedSplice to the user's SPLICE; the bytecode handler unwraps a tied scalar return directly. 5. Negative subscripts on tied arrays passed raw to FETCH/STORE. Perl normalizes negative indices to FETCHSIZE+idx before dispatch. If the result is still negative (e.g. $tied[-100] on a size-3 array), Perl does NOT call FETCH/STORE: reads yield undef, writes throw "Modification of non-creatable array value attempted, subscript -N". Implemented via an outOfRangeOriginalIndex flag on RuntimeTiedArrayProxyEntry, with matching normalization in exists/delete. 6. @tied = (...) didn't call EXTEND. Perl calls EXTEND on tied arrays before the STORE loop. Tie::File relies on this to extend the backing file in autodefer mode. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
077ce69 to
df54e69
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.
Summary
./jcpan -t Tie::Filegoes from 336 failures across 16 test files to all 4725 tests passing, with no regressions in the existing unit tests.Six related bugs in tied-array dispatch and
$.handling, all fixed in the Java runtime:$.numeric reads stale zero afterlocal $.+ reads.ScalarSpecialVariable.set()was cachingthis.type=INTEGER, this.value=0on the proxy.ReadlinemutatescurrentLineNumberdirectly, so the cache goes stale. Numeric comparison fast paths (arg.type==INTEGER→(int)arg.value) then read 0. Removed the sync so$.always delegates throughgetValueAsScalar(). This is why Tie::File's_check_integrityreported "spurious caching of record N" everywhere.$.not incremented for multi-char$/.readUntilStringonly bumpedcurrentLineNumberon\nin the line. With a custom separator containing no newline,$.stayed 0. Now increments once per record read, matching Perl.Tied
push/unshiftreturned the tie method's raw return value.Perl's
av.cignores the PUSH/UNSHIFT return and reportsFETCHSIZE. Tie::File'sPUSHreturns nothing on purpose.tiedPush/tiedUnshiftnow call the handler and then returnFETCHSIZE.Tied
SPLICEalways called in scalar context.tieCallhardcoded SCALAR, so@r = splice(@tied, ...)got back the scalar count. Context now flows throughOperator.spliceandTieArray.tiedSpliceto the user'sSPLICE; the bytecode handler unwraps a tied scalar return directly.Negative subscripts on tied arrays passed raw to FETCH / STORE.
Perl normalizes negative indices (
FETCHSIZE + idx) before dispatch. If the result is still negative (e.g.$tied[-100]on a size-3 array), Perl does NOT call FETCH / STORE: reads yieldundef, writes throwModification of non-creatable array value attempted, subscript -N. Implemented via anoutOfRangeOriginalIndexflag onRuntimeTiedArrayProxyEntry, with matching normalization inexists/delete.@tied = (...)didn't callEXTEND.Perl calls
EXTENDon tied arrays before the STORE loop. Tie::File relies on this to extend the backing file in autodefer mode.Test plan
./jcpan -t Tie::File— 4725/4725 pass (was 4389/4725)make— full unit test suite passes (no regressions)Generated with Devin