Yul constant substitution loses lexical scope

Aperta
#614 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
haskell
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Haskell
Stelle
115
Fork
11
Merge medio
20h 29m
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di argotorg/solcore

Tutte le issue di argotorg/solcore

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.