diff --git a/document/core/valid/modules.rst b/document/core/valid/modules.rst index d982ca34e..ac4f4d720 100644 --- a/document/core/valid/modules.rst +++ b/document/core/valid/modules.rst @@ -719,10 +719,9 @@ The :ref:`external types ` classifying a module may contain f * all other fields are empty. -* Under the context :math:`C'`, - the sequence :math:`\module.\MGLOBALS` of :ref:`globals ` must be :ref:`valid ` with a sequence :math:`\X{gt}^\ast` of :ref:`global types `. +* Under the context :math:`C'`: -* Under the context :math:`C`: + * The sequence :math:`\module.\MGLOBALS` of :ref:`globals ` must be :ref:`valid ` with a sequence :math:`\X{gt}^\ast` of :ref:`global types `. * For each :math:`\table_i` in :math:`\module.\MTABLES`, the definition :math:`\table_i` must be :ref:`valid ` with a :ref:`table type ` :math:`\X{tt}_i`. @@ -730,6 +729,8 @@ The :ref:`external types ` classifying a module may contain f * For each :math:`\mem_i` in :math:`\module.\MMEMS`, the definition :math:`\mem_i` must be :ref:`valid ` with a :ref:`memory type ` :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 ` with a :ref:`function type ` :math:`\X{ft}_i`. @@ -773,9 +774,9 @@ The :ref:`external types ` 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 \\ diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index 5a28beb63..e14fc6d36 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -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 diff --git a/test/core/global.wast b/test/core/global.wast index 3ec4cb727..8c47fde2f 100644 --- a/test/core/global.wast +++ b/test/core/global.wast @@ -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)) @@ -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