Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions document/core/valid/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,18 @@ The :ref:`external types <syntax-externtype>` classifying a module may contain f

* all other fields are empty.

* Under the context :math:`C'`,
the sequence :math:`\module.\MGLOBALS` of :ref:`globals <syntax-global>` must be :ref:`valid <valid-globalseq>` with a sequence :math:`\X{gt}^\ast` of :ref:`global types <syntax-globaltype>`.
* Under the context :math:`C'`:

* Under the context :math:`C`:
* The sequence :math:`\module.\MGLOBALS` of :ref:`globals <syntax-global>` must be :ref:`valid <valid-globalseq>` with a sequence :math:`\X{gt}^\ast` of :ref:`global types <syntax-globaltype>`.

* For each :math:`\table_i` in :math:`\module.\MTABLES`,
the definition :math:`\table_i` must be :ref:`valid <valid-table>` with a :ref:`table type <syntax-tabletype>` :math:`\X{tt}_i`.

* For each :math:`\mem_i` in :math:`\module.\MMEMS`,
the definition :math:`\mem_i` must be :ref:`valid <valid-mem>` with a :ref:`memory type <syntax-memtype>` :math:`\X{mt}_i`.

* Under the context :math:`C`:

* For each :math:`\func_i` in :math:`\module.\MFUNCS`,
the definition :math:`\func_i` must be :ref:`valid <valid-func>` with a :ref:`function type <syntax-functype>` :math:`\X{ft}_i`.

Expand Down Expand Up @@ -773,9 +774,9 @@ The :ref:`external types <syntax-externtype>` classifying a module may contain f
\quad
C' \vdashglobalseq \global^\ast : \X{gt}^\ast
\quad
(C \vdashtable \table : \X{tt})^\ast
(C' \vdashtable \table : \X{tt})^\ast
\quad
(C \vdashmem \mem : \X{mt})^\ast
(C' \vdashmem \mem : \X{mt})^\ast
\quad
(C \vdashfunc \func : \X{ft})^\ast
\\
Expand Down
2 changes: 1 addition & 1 deletion interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,9 @@ let check_module (m : module_) =
|> check_list check_type m.it.types
|> check_list check_import m.it.imports
|> check_list check_func m.it.funcs
|> check_list check_global m.it.globals
|> check_list check_table m.it.tables
|> check_list check_memory m.it.memories
|> check_list check_global m.it.globals
|> check_list check_elem m.it.elems
|> check_list check_data m.it.datas
in
Expand Down
11 changes: 9 additions & 2 deletions test/core/global.wast
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,10 @@
(global $g2 i32 (global.get $g0))
(global $g3 i32 (global.get $g1))

(global $gn funcref (ref.null func))
(global $gf funcref (ref.func $f))
(func $f)

(table $t 10 funcref (global.get $gn))
(table $t 10 funcref (ref.null func))
(elem (table $t) (global.get $g2) funcref (ref.func $f))
(elem (table $t) (global.get $g3) funcref (global.get $gf))

Expand Down Expand Up @@ -660,6 +659,14 @@
"unknown global"
)

(assert_invalid
(module
(global $g funcref (ref.null func))
(table $t 10 funcref (global.get $g))
)
"unknown global"
)


;; Duplicate identifier errors

Expand Down