Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[js-api] A mutable global import allocates a const global before LinkError

Abierto
#2,253 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@chicoxyzzy ya está trabajando en esto.

Desde el 5/10/2026.

  • #2263 de @chicoxyzzy — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
wasm
Área
compilers

Línea de trabajo

Start with the JS API “read the imports” algorithm and trace its interaction with module_instantiate and global_alloc; compare it with the old ExecuteModule path described in the issue. Done means mismatched mutable/const global imports throw LinkError before allocation, while successful fresh-value allocation uses the import mutability.

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

Descripción

In read the imports, a global import ignores mut:

If externtype is of the form global mut valtype,
    If v implements Global,
        Let globaladdr be v.[[Global]].
    Otherwise,
        …
        Let (store, globaladdr) be global_alloc(store, const valtype, value).
        Set the surrounding agent's associated store to store.

module_instantiate still rejects a mismatch, so the link fails. The store update happens first.

  • A var import whose value is not a Global allocates a const global, then the type check fails. That global stays in the store and is not exposed to JavaScript.
  • A const import of a var Global reuses that global and fails the same check. Nothing new is allocated.

A number can only successfully import a const global, so the allocation on the var path is always discarded.

This showed up while sharing the reader with ESM integration (discussion). The old ExecuteModule path threw LinkError before allocation when mut was var and the value was not a Global, and when a const import was a var Global. Matching the JS API drops those checks.

Suggested change, before global_alloc:

  • If the value is not a Global and mut is var, throw a LinkError.
  • If the value is a Global, mut is const, and that global is var, throw a LinkError.
  • Otherwise allocate with the import's mut. For a fresh value that is only const.
Lenguaje dominante
WebAssembly
Estrellas
3.5k
Forks
539
Merge medio
10 h 24 min
PR fusionados (30 d)
11

Preparar el entorno

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 WebAssembly/spec

Todos los issues de WebAssembly/spec

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.