Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#2,253 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@chicoxyzzy がすでに取り組んでいます。

2026年10月5日 から。

  • #2263 @chicoxyzzy による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
wasm
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
WebAssembly
スター
3.5k
フォーク
539
平均マージ
10時間 24分
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WebAssembly/spec のほかの issue

WebAssembly/spec の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。