[interpreter] Reject subtypes with multiple supertypes - #2232
Open
sanguineman wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WebAssembly allows a subtype to refer to a previously declared parent type as its supertype. The current specification restricts a subtype to have at most one direct supertype.
It also notes that future versions of WebAssembly may allow subtypes to have more than one supertype.
The validation specification written in SpecTec correctly enforces this restriction by requiring the number of direct supertypes to be at most one.
However, the OCaml reference interpreter does not check the number of direct supertypes. It only iterates over the supertype list and validates each referenced type individually.
Consequently, the reference interpreter accepts subtype definitions with multiple direct supertypes, even though the current declarative specification requires them to be rejected.
This PR adds the missing cardinality check to
check_subtype. It also adds a regression test containing two valid non-final parent struct types and a child type that directly inherits from both. The module is rejected specifically because the child has more than one direct supertype.Testing
make -C interpreter test/gc/type-subtypingmake -C interpreter unittest