Skip to content

Commit 62893c2

Browse files
authored
[spec] Update the definition of tagtype and its subtyping (WebAssembly#1862)
1 parent 9d91344 commit 62893c2

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

document/core/syntax/types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,11 @@ Global Types
483483
Tag Types
484484
~~~~~~~~~
485485

486-
*Tag types* classify the signature of :ref:`tags <syntax-tag>` with a function type.
486+
*Tag types* classify the signature of :ref:`tags <syntax-tag>` with a defined type |deftype|, which expands to a function type |functype|.
487487

488488
.. math::
489489
\begin{array}{llll}
490-
\production{tag type} &\tagtype &::=& \functype \\
490+
\production{tag type} &\tagtype &::=& \deftype \\
491491
\end{array}
492492
493493
Currently tags are only used for categorizing exceptions.

document/core/valid/instructions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,15 +2601,15 @@ Control Instructions
26012601

26022602
* The tag :math:`C.\CTAGS[x]` must be defined in the context.
26032603

2604-
* Let :math:`[t^\ast] \to [{t'}^\ast]` be the :ref:`tag type <syntax-tagtype>` :math:`C.\CTAGS[x]`.
2604+
* Let :math:`[t^\ast] \to [{t'}^\ast]` be the :ref:`expansion <aux-expand-deftype>` of the :ref:`tag type <syntax-tagtype>` :math:`C.\CTAGS[x]`.
26052605

26062606
* The :ref:`result type <syntax-resulttype>` :math:`[{t'}^\ast]` must be empty.
26072607

2608-
* Then the instruction is valid with type :math:`[t_1^\ast t^\ast] \to [t_2^\ast]`, for any sequences of :ref:`value types <syntax-valtype>` :math:`t_1^\ast` and :math:`t_2^\ast`.
2608+
* Then the instruction is valid with type :math:`[t_1^\ast t^\ast] \to [t_2^\ast]`, for any sequences of :ref:`value types <syntax-valtype>` :math:`t_1^\ast` and :math:`t_2^\ast`.
26092609

26102610
.. math::
26112611
\frac{
2612-
C.\CTAGS[x] = [t^\ast] \to []
2612+
\expanddt(C.\CTAGS[x]) = [t^\ast] \to []
26132613
}{
26142614
C \vdashinstr \THROW~x : [t_1^\ast~t^\ast] \to [t_2^\ast]
26152615
}

document/core/valid/matching.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,14 +580,22 @@ A :ref:`global type <syntax-globaltype>` :math:`(\mut_1~t_1)` matches :math:`(\m
580580
Tag Types
581581
~~~~~~~~~
582582

583-
A :ref:`tag type <syntax-tagtype>` :math:`\tagtype_1` matches :math:`\tagtype_2` if and only if they are the same.
583+
A :ref:`tag type <syntax-tagtype>` :math:`\deftype_1` matches :math:`\deftype_2` if and only if the :ref:`defined type <syntax-deftype>` :math:`\deftype_1` :ref:`matches <match-deftype>` :math:`\deftype_2`, and vice versa.
584584

585585
.. math::
586586
\frac{
587+
C \vdashdeftypematch \deftype_1 \matchesdeftype \deftype_2
588+
\qquad
589+
C \vdashdeftypematch \deftype_2 \matchesdeftype \deftype_1
587590
}{
588-
C \vdashtagtypematch \tagtype \matchestagtype \tagtype
591+
C \vdashtagtypematch \deftype_1 \matchestagtype \deftype_2
589592
}
590593
594+
.. note::
595+
Although the conclusion of this rule looks identical to its premise,
596+
they in fact describe different relations:
597+
the premise invokes subtyping on defined types,
598+
while the conclusion defines it on tag types that happen to be expressed as defined types.
591599

592600
.. index:: external type, function type, table type, memory type, global type
593601
.. _match-externtype:

document/core/valid/types.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,19 +551,25 @@ Memory Types
551551
Tag Types
552552
~~~~~~~~~
553553

554-
:math:`[t_1^n] \to [t_2^m]`
555-
...........................
554+
:math:`\deftype`
555+
................
556556

557-
* The :ref:`function type <syntax-functype>` :math:`[t_1^n] \to [t_2^m]` must be :ref:`valid <valid-functype>`.
557+
558+
* The :ref:`defined type <syntax-deftype>` :math:`\deftype` must be :ref:`valid <valid-deftype>`.
559+
560+
* The :ref:`expansion <aux-expand-deftype>` of :math:`\deftype` must be a :ref:`function type <syntax-functype>` :math:`\TFUNC~[t_1^n] \toF [t_2^m]`.
558561

559562
* The type sequence :math:`t_2^m` must be empty.
560563

561564
* Then the tag type is valid.
562565

563566
.. math::
564567
\frac{
568+
C \vdashdeftype \deftype \ok
569+
\qquad
570+
\expanddt(\deftype) = \TFUNC~[t^\ast] \to []
565571
}{
566-
\vdashtagtype [t^\ast] \to [] \ok
572+
C \vdashtagtype \deftype \ok
567573
}
568574
569575

0 commit comments

Comments
 (0)