Fix sysread/read type corruption on tied scalars#248
Merged
Conversation
BYTE_STRING fixes: - substr on BYTE_STRING now preserves type instead of returning STRING - 4-arg substr preserves BYTE_STRING type on extracted substring - read() sets BYTE_STRING type for non-UTF8 file handles - sysread returns BYTE_STRING via byte[] constructor in all IO classes (@) prototype fix: - handleListOrHashArgument no longer passes obeyParentheses=true to parseZeroOrMoreList, since outer parens are already consumed by consumeArgsWithPrototype. This fixes expressions like Set64u(($dat + 11644473600) * 1e7) being rejected as "Too many arguments" when the inner parens were misinterpreted as argument list delimiters. Ref: #93 Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
The BYTE_STRING type preservation added in 8ee53eb directly sets target.type after sysread/read, which corrupts tied scalars by overwriting their TIED_SCALAR type while the value field still holds the TieScalar object. This causes a ClassCastException when the scalar is later accessed as a string. Guard the direct type assignments with a TIED_SCALAR check so tied variables retain their proper type semantics. Fixes gmagic.t regression (27/35 → 31/42). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
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
ClassCastException: TieScalar cannot be cast to Stringcrash inop/gmagic.tcaused by directtarget.typefield assignment corrupting tied scalar state aftersysread/readTIED_SCALARtype on tied variables while thevaluefield still held theTieScalarobject, causing later string access to fail with a cast exceptionsysread()andread()with aTIED_SCALARcheckTest plan
op/gmagic.trestored to 31/42 (matching master baseline)mvn test)Generated with Devin