Repository navigation
Conversation
Contributor
|
This was referenced Oct 7, 2026
gnidan
added a commit
that referenced
this pull request
Oct 7, 2026
* bugc: compile `!` as a logical not * bugc: link the changelog entry to #353 * bugc: end each source range at its last token * bugc: link the changelog entry to #362 * bugc: add block.prevrandao * bugc: link the changelog entries to #363 * bugc: hash several value-type words with keccak256 * bugc: link the changelog entries to #365 * bugc: slice a fixed-size bytes value by its bytes * bugc: link the changelog entry to #357 * bugc: hash the data of dynamic bytes and strings * bugc: link the changelog entry to #360 * bugc: give a caller's call JUMP the invoke's arguments * bugc: list variables before a function's first statement * bugc: store a memory string's bytes when assigning it to storage A storage write took its value as a word, so a memory string or bytes reference wrote its memory address into the slot. Code generation now encodes the referenced bytes as Solidity does: inline with length * 2 up to 31 bytes, else length * 2 + 1 in the slot and the data from keccak256(slot), with the last word's trailing bytes cleared. A slice now carries the bytes type, so its value is recognized too. * bugc: link the changelog entry to #355 * bugc: say why the bytes test slices without naming the copy width * bugc: copy all of a slice's bytes irgen built a slice's data as a read and a write, and a read or write moves at most one word, so only the first 32 bytes were copied. Add a copy IR instruction (CALLDATACOPY from calldata, MCOPY from memory) and emit it for the slice's data. * bugc: link the changelog entries to #359 * bugc: copy a struct read from storage into memory * bugc: link the changelog entries to #361 * bugc: lay storage arrays out as Solidity does * bugc: add push to dynamic arrays in storage
Member
Author
|
Included in #368. |
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.
let p = players[who];, withplayers: mapping<address, Player>, compiled to a read of the struct's first storage slot, typed as a memory reference. Sop.scoreread memory at an address equal to that slot's word, andp.score = 0failed code generation (irgen emitted acompute_offsetwith nooffsetKind, which evmgen does not handle). The same held for a storage struct variable,let p = stored;.The examples' README says what this should mean: "when you read a complex type (struct, array, or mapping) from storage into a local variable, you get a copy of the data, not a reference", and a write to the copy does not update storage. This implements that for structs:
stringor dynamicbytesfield is an error that names the field. Copying those from storage needs more than one word per field, and nothing in bugc builds them in memory from storage yet.compute_offset.Copying a struct with more than a few fields exposed a bug in evmgen's memory planning: when it simulated the stack to find values that need a memory home, it did not count the operands of
read,writeandcompute_offsetas uses. So a value whose later uses were all of those kinds (here, the copy's address) got no home, and code generation failed with "Cannot load value". Those operands now count.The open question is whether BUG should also have storage references (Solidity's
Player storage p). Copy semantics is what the README describes, so that is what this does; arrays read from storage into a local are not changed here.