Yul constant substitution loses lexical scope
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start by reading MastEval.escapingAssignsYulBlock and substYulStmt, the scope handling paths named in the issue. Trace how nested Yul declarations, loop initializers, and later assembly blocks affect constant invalidation and substitution. Done means the examples preserve the outer assignment and substitute 7 in both positions while keeping the loop-local binding.
Written by the indexing model from the issue text.
Description
A declaration in a nested Yul block hides an earlier write to an outer variable from the constant invalidation logic. A later read is then incorrectly replaced with the old constant.
contract C {
function main() returns (word) {
let x: word = 0;
let y: word = 0;
assembly {
if calldatasize() { x := 5 { let x := 9 } }
y := x
}
return y;
}
}
Actual: the emitted Hull contains y := 0. Expected: keep y := x,
so the result can be 5 when calldata is nonempty. The nested let x must not
hide the outer assignment.
Loop initializers and later assembly blocks can also retain references to an outer comptime binding that has already been erased:
contract C {
function main() returns (word) {
let seed: comptime<word> = 7;
let y: word = 0;
assembly {
for { let seed := seed } lt(seed, 9) { seed := add(seed, 1) } {
y := add(y, seed)
}
}
assembly { y := add(y, seed) }
return y;
}
}
Actual: the outer comptime seed is erased, but the loop initializer still
contains let seed := seed, and the later assembly block retains an unbound
seed. Expected: substitute 7 in both positions while preserving the
loop-local binding. MastEval.escapingAssignsYulBlock and substYulStmt appear
to be the relevant scope-handling paths.
- Dominant language
- Haskell
- Stars
- 115
- Forks
- 11
- Avg merge
- 20h 29m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from argotorg/solcore
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
user feedback: Rename `lam` to `lambda` and give the unit type a namePossibly taken @rodrigogribeiro claimed this 50 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
All issues in argotorg/solcore
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
IntersectMBO/cardano-ledger#6276 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/canton-contracts#92 ·
Maintainers usually reply within 1 day