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

Abierto
#2,474 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C
Estrellas
3
Forks
7
Merge medio
3 h 28 min
PR fusionados (30 d)
270

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de InauguralSystems/EigenScript

Todos los issues de InauguralSystems/EigenScript

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.