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

Offen
#2,474 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
c
Bereich
compilers

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
C
Sterne
3
Forks
7
Ø Merge
3 Std. 28 Min.
Gemergte PRs (30 T.)
270

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus InauguralSystems/EigenScript

Alle Issues in InauguralSystems/EigenScript

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.