Treat exn as a heap type so (ref exn) is non-nullable - #2818
Open
chicoxyzzy wants to merge 1 commit into
Open
Conversation
exnref is the nullable valtype (0x69). The non-nullable form is (ref exn) (0x64 0x69), matching funcref vs (ref func). Parse (ref exn) / (ref null exn), read and write the typed-ref encoding, and apply the same nullability subtyping as FuncRef and ExternRef. catch_ref still produces exnref, matching the current exception-handling testsuite.
chicoxyzzy
force-pushed
the
eng/exn-heap-type
branch
from
August 11, 2026 02:42
b094b3e to
81a4c9b
Compare
Member
|
@zherczeg has been doing a lot work on reference types (GC types), which has been stuck in the review queue. Not sure how this fits in (or not) with that work? |
Collaborator
|
This is part of #2607 . It also includes support for |
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.
exnrefis the nullable valtype (0x69). The non-nullable form is(ref exn)(0x64 0x69), the same split asfuncrefvs(ref func).Before this, the lexer knew the
exnkeyword but bothexnandexnrefwere the sameType::ExnRefvaltype.(ref exn)failed to parse (unexpected token "exn", expected a numeric index or a name), and the binary reader rejected0x64 0x69as a heap type.This change:
ExnRefas a non-typed reference with nullability (ReferenceOrNullvsReferenceNonNull), likeFuncRef/ExternRef.(ref exn)and(ref null exn).exnref/(ref null exn)still emit0x69.(ref exn)is a subtype ofexnrefand not the other way around.catch_refstill produces nullableexnref. The pinned exception-handling testsuite uses(block (result exnref) (try_table (catch_ref …)))and checks those types exactly, so flipping that would fail every officialthrow_ref/try_tabletest.Tests:
test/parse/expr/exn-ref.txt,exn-ref-as-non-null.txt,bad-exn-ref-nullable.txt,test/roundtrip/exn-ref.txt. Also ran parse, roundtrip, dump,test/spec/exception-handling, andtest/spec/function-references.