fix(ergotree-interpreter): implement numeric cast to UnsignedBigInt in eval#878
Open
mwaddip wants to merge 1 commit into
Open
fix(ergotree-interpreter): implement numeric cast to UnsignedBigInt in eval#878mwaddip wants to merge 1 commit into
mwaddip wants to merge 1 commit into
Conversation
…n eval
Upcast/Downcast to UnsignedBigInt had no eval arm, so the `_` catch-all
errored ("Upcast: expected numeric value" / "Downcast: ..."). Add the
SUnsignedBigInt target arm to both, mirroring Scala
SUnsignedBigInt.upcast/downcast: widen Byte/Short/Int/Long, pass an
UnsignedBigInt through unchanged, and reject negative values (the JVM
errors when widening a negative numeric to UnsignedBigInt). There is
deliberately no signed-BigInt source arm (ErgoScript uses .toUnsigned).
Surfaced by a full node on testnet block 28,474 (an Autolykos-2 verify),
which maps Global.powHit over a collection and runs
Upcast(Int -> UnsignedBigInt) in the exists predicate.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Upcast/DowncasttoUnsignedBigInthad no eval arm, so evaluating one hit the_catch-all and errored ("expected numeric value"). This adds theSUnsignedBigInttarget arm to both, mirroring ScalaSUnsignedBigInt.upcast/downcast: widenByte/Short/Int/Long, pass anUnsignedBigIntthrough unchanged, and reject negatives (the JVM errors when widening a negative numeric toUnsignedBigInt). No signed-BigIntsource arm — ErgoScript uses.toUnsigned.Surfaced by a full node on testnet block 28,474 (Autolykos-2 verify):
coll.map(x => Global.powHit(..)).exists((u: UnsignedBigInt) => ..), whose predicate runsUpcast(Int -> UnsignedBigInt). JVM 6.0.3 accepts it.Tests cover each source type, the identity pass-through, and negative / signed-BigInt rejection.