Repository navigation
bugc: string and bytes calldata parameters - #383
Merged
Merged
Conversation
A function parameter may be `string calldata` or `bytes calldata`. Its argument must be in calldata too, and passes as its word of offset and length, with no copy to memory, in a real call and when the function is inlined. The parameter's pointer is that of a calldata `let`.
Contributor
|
A call whose callee has no function type is now an error, not a call that copies every argument to memory. New tests run a calldata parameter's copy to a string, keccak256, a string return value, an argument to a string parameter, and a tail-recursive function at O0 to O3, and check a bytes calldata parameter's pointer.
This was referenced Oct 15, 2026
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.
A function parameter may now be
string calldataorbytes calldata, so a contract can hand a reference into its call data to a function without copying it:#367 and #379 limited these types to a
letor a cast (TYPE016) to keep their scope small; nothing in the calling convention needs it. A calldata reference is one word (offset in the high 128 bits, length in the low 128), so it passes as any word argument does. The call site now skips the copy to memory when the parameter is in calldata, and a parameter of the plainstringorbytestype still gets a copy. The argument must itself be in calldata, with the same rules as aletof that type: a string in memory, orbytes calldatawithout a cast, is a type error for astring calldataparameter. A return type, struct field, storage variable or nested type of calldata is stillTYPE016.The parameter's IR type is the calldata reference, so its debug info is a calldata
let's: the parameter's word, then a calldata region whose offset and length are computed from it.Tests:
string calldataand abytes calldataparameter of 0, 31, 32, 33 and 65 bytes are stored and indexed, through a leaf function (inlined at O2 and O3) and through a function with two returns that passes its parameter on (a real call at every level). The IR has calldata parameter types and no extra copy.The BUG case study and the changelog are updated.