fix: fix three bugs causing Parse::Yapp test failures#505
Merged
Conversation
1. Indirect object notation: Allow `new Class(args)` when Class is
not known at compile time (e.g., created via eval). Fixed by only
rejecting indirect object syntax when the method IS a known function.
2. pack('b'.$n) zero-fill: pack with bit template and no data args
now correctly returns zero-filled bytes (ceil(count/8)) instead of
an empty string.
3. Bitwise operator string/numeric dispatch: Replace looksLikeNumber()
heuristic with type-based dispatch matching Perl 5 semantics (SvNIOKp).
Bitwise ops now use numeric path only when either operand has a native
numeric type (INTEGER/DOUBLE), and string path when both are strings.
This fixes corruption of pack/vec strings by $s |= $s and also fixes
"05" | "03" to correctly return "07" (string OR) instead of 7.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The bitwise dispatch change (type-based instead of looksLikeNumber) caused a regression in op/bop.t: binary&=, binary|=, binary^= (from use feature "bitwise") were sharing opcodes with the regular &=, |=, ^= which now use type-based dispatch. Under the bitwise feature, these must always use numeric operations regardless of operand type. Fix: add dedicated BINARY_AND_ASSIGN/OR/XOR opcodes (468-470) and route binary&/|/^ to BINARY_AND/OR/XOR opcodes that call the always-numeric bitwiseAndBinary/OrBinary/XorBinary directly. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
d594b98 to
b75d5e0
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
Fixes three bugs that caused Parse::Yapp test failures when run via
jcpan -t Parse::Yapp:Bug 1: Indirect object notation with eval-created classes
SubroutineParser.javanew Test(yylex => $lex)failed whenTestwas created viaeval(not known at compile time)Bug 2:
pack('b'.$n)with no data argumentsPackWriter.javapack('b825')returned empty string instead of 104 zero-filled bytes (ceil(825/8))Bug 3: Bitwise operator string/numeric dispatch (root cause of stress.t failure)
BitwiseOperators.javalooksLikeNumber()heuristic with type-based dispatch matching Perl 5 semantics (SvNIOKp)&,|,^,~now use the numeric path only when either operand has a native numeric type (INTEGER/DOUBLE), and the string path when both are non-numeric$s |= $scorruption on pack/vec strings (the_Digraphfunction inParse::Yapp::Lalrdepends on this)"05" | "03"now correctly returns"07"(string OR) instead of7(numeric OR)Test plan
makepasses (all unit tests)jcpan -t Parse::Yapp— all 3 test files pass (t/base.t, t/calc.t, t/stress.t)Generated with Devin