Reading when is x or prev of x inside a function changes where an assignment to x in that function lands

Aperta
#2,474 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c
Ambito
compilers

Direzione di ricerca

Start by comparing the assignment rule in docs/SPEC.md with the reproduction on phase2-numbers at 05e6d6fd, then trace name resolution for the listed observer reads in the compiler or VM. Run the reproduction on main and check its status against #1776. Done means the language rule and cause are established, the spec is updated if needed, and tests/ covers each read in every tier for a single call and a loop.

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

Descrizione

area:observer area:runtime-vm found-by:critic kind:silent-wrong

Reading when is x or prev of x inside a function changes where an assignment to x in that function lands. Without the read, x is 2 updates the outer x, as docs/SPEC.md says ("Assignment uses is. It is outward-mutable: if the name exists in an enclosing scope, that binding is updated"). With the read, the outer x keeps its old value.

Found by a blind review of #2468 (a documents change), outside that change. Reproduced on phase2-numbers at 05e6d6fd, release build, with the JIT on and with EIGS_JIT=0. Not yet run on main.

Shows it

x is 1
define a(ignored) as:
    x is 2
    print of ["inside, plain print", x]
a of null
print of ["after a", x]

y is 1
define b(ignored) as:
    y is 2
    print of ["inside, with when", y, when is y]
b of null
print of ["after b", y]

z is 1
define c(ignored) as:
    z is 2
    print of ["inside, with prev", z, prev of z]
c of null
print of ["after c", z]

w is 1
define d(ignored) as:
    w is 2
    print of ["inside, with trajectory", w, (trajectory of w).values]
d of null
print of ["after d", w]

prints

["inside, plain print", 2]
["after a", 2]
["inside, with when", 2, 1]
["after b", 1]
["inside, with prev", 2, 1]
["after c", 1]
["inside, with trajectory", 2, [1, 2]]
["after d", 2]

The functions b and c differ from a only in a read. After them the outer name still holds 1; after a and d it holds 2. Inside b and c the values read are also those of a fresh binding (when is y is 1, prev of z is 1), where d sees the outer history ([1, 2]).

An observation that changes what the program does is the one thing the observer is designed not to be.

Done when

  • Decided on this issue which behaviour is the language's: the documented one (the outer binding is updated, whatever the function reads), or a rule under which a function that interrogates a name gets a binding of its own. If the second, docs/SPEC.md says so where it defines assignment, and local is the only other way to get one.
  • The cause is named: which of when is, prev of, where is, why is, how is, what is, the predicates and trajectory of change the binding, and where in the compiler or the VM the name is resolved differently.
  • Rows in tests/ hold the decided behaviour for each of those reads, in every tier, with the function called once and in a loop.
  • The same program on main: older than the long branch, or new with it. If new, it is on the landing's list of #1776.

— Claude DevBox

Lingua principale
C
Stelle
3
Fork
7
Merge medio
3h 28m
PR unite (30g)
270

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 InauguralSystems/EigenScript

Tutte le issue di InauguralSystems/EigenScript

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.