Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Adds validation for exception results. #254

Merged
merged 7 commits into from
Apr 21, 2023

Conversation

ioannad
Copy link
Collaborator

@ioannad ioannad commented Feb 16, 2023

Uses the "current" version of exception results, as it will be changed by #226.

Uses the "current" version of exception results, as it will be changed by WebAssembly#226.
@ioannad ioannad requested a review from rossberg February 16, 2023 12:58
:ref:`Results <syntax-result>` :math:`\val^\ast~(\THROWadm~\tagaddr)`
.....................................................................

* The :ref:`tag address <syntax-tagaddr>` :math:`\tagaddr` must be in :math:`\moduleinst.\MITAGS`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That isn't right, it may come from any module. It must only exist in the store, which is already verified by the next step.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


* Let :math:`[t_1^\ast]\to[]` be the :ref:`tag type <syntax-tagtype>` |tagtype|.

* The values :math:`\val^\ast` must be :ref:`valid <valid-val>` with types :math:`[t_1^\ast]`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sequence of values does not form a result itself here, so we shouldn't type it against a result type. Rather use the same "loop" as in the regular result case (mirroring what the formal rule does).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ioannad ioannad requested a review from rossberg March 3, 2023 13:21
* The :ref:`external value <syntax-externval>` :math:`\EVTAG~\tagaddr` must be :ref:`valid <valid-externval-tag>` with some :ref:`external type <syntax-externtype>` :math:`\ETTAG~\tagtype`.

* Let :math:`[t_1^\ast]\to[]` be the :ref:`tag type <syntax-tagtype>` |tagtype|.
* Let :math:`[t^\ast]\to[{t'}^\ast]` be the :ref:`tag type <syntax-tagtype>` |tagtype|.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a step missing after this one that checks that t'* is empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added assertion.


* Then the result is valid with :ref:`result type <syntax-resulttype>` :math:`[t_2^\ast]`, for any sequence :math:`t_2^\ast` of :ref:`value types <syntax-valtype>`.
* Then the result is valid with :ref:`result type <syntax-resulttype>` :math:`[{t'}^\ast]`, for any sequence :math:`{t'}^\ast` of :ref:`value types <syntax-valtype>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a name clash, this is a different t'*.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the first occurrence to t_0^\ast.

@ioannad ioannad requested a review from rossberg March 10, 2023 12:11

* Let :math:`[t^\ast]\to[t_0^\ast]` be the :ref:`tag type <syntax-tagtype>` |tagtype|.

* Assert: due to :ref:`validation <valid-externval-tag>` the type sequence :math:`t_0^\ast` must be empty.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually an assertion -- this rule is the very one that validates this property for results. ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the first line (L.65) do this validation?

  • The :ref:external value <syntax-externval> :math:\EVTAG~\tagaddr must be :ref:valid <valid-externval-tag> with some :ref:external type <syntax-externtype> :math:\ETTAG~\tagtype.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's the justification, so removing the "Assert:"

@ioannad ioannad requested a review from rossberg March 17, 2023 16:34
@@ -66,9 +66,9 @@ Results

* Let :math:`[t^\ast]\to[t_0^\ast]` be the :ref:`tag type <syntax-tagtype>` |tagtype|.

* Assert: due to :ref:`validation <valid-externval-tag>` the type sequence :math:`t_0^\ast` must be empty.
* Due to :ref:`validation <valid-externval-tag>` the type sequence :math:`t_0^\ast` must be empty.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Due to :ref:`validation <valid-externval-tag>` the type sequence :math:`t_0^\ast` must be empty.
* The type sequence :math:`t_0^\ast` must be empty.

It's not due to some other validation, this rule is the validation. ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To expand on this, there are several layers:

  • Externval-tag validity, which you referenced here, does not actually check that the referenced tag instance is valid (and this rule does not know if the store is valid).
  • Tag instance validity (as part of store validity) checks that the tag type is valid.
  • Tag type validity checks that the result is empty (but see below).

You can actually combine the first three bullets in this rule into one by saying something like "The extern value TAG tagaddr must be valid with some external type TAG [t^\ast]->[]." This style is already used in some of the other rules, I believe, e.g. THROWadm.

Finally, I noticed that we are currently a bit inconsistent: tag type validity requires that the result is empty, but we are simply assuming, not asserting that in various places of the prose (e.g., the validation rule for THROW). My preference for fixing this would be to not treat tag types with empty results as invalid themselves, but only enforce emptiness in the exception-related use site rules.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Externval-tag validity, which you referenced here, does not actually check that the referenced tag instance is valid (and this rule does not know if the store is valid).

Thank you, I think I missed that point. I saw that externval-tag validation does check if the tag is valid, and I forgot that it's not aware of the store's validity.

I will implement your second suggestion to combine the first three bullets. This way it's shorter and consistent with THROWadm validation.

Finally, I noticed that we are currently a bit inconsistent: tag type validity requires that the result is empty, but we are simply assuming, not asserting that in various places of the prose (e.g., the validation rule for THROW). My preference for fixing this would be to not treat tag types with empty results as invalid themselves, but only enforce emptiness in the exception-related use site rules.

I will create a new PR to make these changes, to not mix up the conversations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossberg

I will implement your second suggestion to combine the first three bullets. This way it's shorter and consistent with THROWadm validation.

Done.

@ioannad ioannad requested a review from rossberg April 14, 2023 16:12
@ioannad ioannad merged commit 24440ac into WebAssembly:main Apr 21, 2023
@ioannad ioannad deleted the validation-for-exception-results branch April 21, 2023 13:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants