fix(sema): reject address.transfer / address.send on Soroban target#1915
Open
gabrielrondon wants to merge 1 commit into
Open
fix(sema): reject address.transfer / address.send on Soroban target#1915gabrielrondon wants to merge 1 commit into
gabrielrondon wants to merge 1 commit into
Conversation
Soroban contracts do not have a native value-transfer model: balances
move through the Stellar Asset Contract (SAC) or the token interface,
not the contract runtime. Compiling `<payable>.transfer(...)` or
`<payable>.send(...)` for `--target soroban` was reaching codegen and
panicking at `src/emit/instructions.rs:989` ("Found IntValue") while
lowering `Instr::ValueTransfer`.
Mirror the existing Solana guard one block above and reject both
methods at sema time with a Soroban-specific diagnostic pointing the
user toward SAC.
Adds regression tests asserting the diagnostic is emitted for both
methods.
Fixes hyperledger-solang#1909
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
Soroban contracts do not have a native value-transfer model: balances move through the Stellar Asset Contract (SAC) or the token interface, not the contract runtime. Compiling
<payable>.transfer(...)or<payable>.send(...)for--target sorobanwas reaching codegen and panicking atsrc/emit/instructions.rs:989("Found IntValue") while loweringInstr::ValueTransfer.This PR mirrors the existing Solana guard at
src/sema/expression/function_call.rs:1295and rejects both methods at sema time on the Soroban target with a Soroban-specific diagnostic pointing the user toward SAC / the token interface.Fixes #1909.
MRE (from #1909)
Before:
solang compile --target soroban mre.solpanics atinkwell-0.4.0/src/values/enums.rs:278: Found IntValue(...).After: rejected at sema with a clear diagnostic.
Test plan
cargo test --features sorobanaddress_transfer_is_rejected_on_sorobanandaddress_send_is_rejected_on_sorobanpassLocal validation:
cargo check --tests --features sorobanis clean. Full test run was not exercised locally because the macOS + LLVM 16 link path is fiddly; leaving the heavy lifting to CI.