Skip to content

[spec] Define the syntax of exact heap types#93

Merged
tlively merged 9 commits intomainfrom
spectec-exact-heap-type-syntax
Feb 3, 2026
Merged

[spec] Define the syntax of exact heap types#93
tlively merged 9 commits intomainfrom
spectec-exact-heap-type-syntax

Conversation

@tlively
Copy link
Member

@tlively tlively commented Jan 30, 2026

No description provided.

Update backend-interpreter/construct.ml to avoid compile errors in the
due to the changes to the type system in the reference interpreter. Stub
out most of the handling of new functionality and leave TODOs so we can
easily find the places to update later.
As described in the overview, relax validation so that the input and
output types need only be in the same hierarchy rather than requiring
that the output type be a subtype of the input type.

In addition to updating the SpecTec source of truth, add notes about
what the extra supertypes in the formal rules are achieving. These notes
are modeled on the similar note that already exists for ref.cast_desc.
@tlively tlively requested a review from rossberg January 30, 2026 01:37
@tlively
Copy link
Member Author

tlively commented Jan 30, 2026

@rossberg,

When I switch the order of variants to have exact types first, I get a fairly opaque error.

syntax heaptype hint(desc "heap type") =
  | absheaptype | EXACT typeuse | typeuse

produces:

../../specification/wasm-3.0/1.2-syntax.types.spectec:44.19-44.32: type error: parent type's type `{EXACT typeuse}` does not match type | ...

The span it is referring to contains EXACT typeuse. Can you explain why this is erroneous and what the error message means?

@tlively tlively mentioned this pull request Jan 30, 2026
50 tasks
Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

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

Yeah, the parser expects all parent types to come first. You should actually get an error "misplaced type", but there is a bug in the error detection logic. (Because of the parent typeuse after it, the parser instead tries to parse EXACT typeuse as a type expression referring to another parent variant type.)

@rossberg
Copy link
Member

rossberg commented Feb 2, 2026

FWIW, I just relaxed parsing to allow any order. I think the EXACT case should still go last in this example, though.

Base automatically changed from spectec-relax-br-on-cast-validation to main February 3, 2026 06:02
@tlively tlively merged commit 4a46e98 into main Feb 3, 2026
11 of 12 checks passed
@tlively tlively deleted the spectec-exact-heap-type-syntax branch February 3, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants