Skip to content

Commit 46de3c4

Browse files
authored
Update inhabitability of exact reference types (#16)
Make all non-nullable references to abstract heap types uninhabited without exception. This is the maximally conservative choice in that it preserves our ability to refine the types of instructions that produce references to abstract heap types in the future.
1 parent 2a143d7 commit 46de3c4

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

proposals/custom-descriptors/Overview.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,17 @@ we have:
291291
where `bot` is the bottom type
292292
(e.g. `none`, `nofunc`, `noextern`, `noexnt`, or `nocont`) of `ht`'s hierarchy.
293293

294-
All instructions that create reference to a particular heap type
295-
(e.g. `ref.func`, `struct.new`, `array.new`, `ref.i31`, `ref.null`, etc.)
294+
All instructions that create reference to a particular defined heap type
295+
(e.g. `ref.func`, `struct.new`, `array.new`, etc.)
296296
are refined to produce exact references to that heap type.
297-
In contrast, `any.convert_extern` and `extern.convert_any` never produce exact references.
298-
`(ref exact any)` and `(ref exact extern)` are uninhabited.
299-
Internalized host references and externalized internal references are modeled
300-
as having "hidden" subtypes of `any` and `extern`,
301-
respectively.
297+
In contrast, instructions that produce references to abstract heap types
298+
generally do not produce exact references.
302299
This preserves our ability to assign them more specific types in the future.
303-
304-
In fact, non-nullable exact references to most abstract heap types are uninhabited.
305-
The only exceptions are:
306-
307-
- `(ref exact i31)` and `(ref exact (shared i31))`, which are inhabited by i31 references.
308-
- `(ref exact exn)`, which is inhabited by exception references.
309-
- `(ref exact (shared waitqueue))`,
310-
which is inhabited by waitqueue references from the shared-everything threads proposal
311-
312-
Note that this will prevent us from ever introducing more specific subtypes of `i31`, `exn`, and `waitqueue`.
300+
For example, `ref.i31` produces `(ref i31)`, not `(ref exact i31)`,
301+
and casting an `i31` reference (or anything else) to `(ref exact i31)` will fail.
302+
The only exception to this rule is that `ref.null ht` is typed `(ref null exact ht)`.
303+
This allows `ref.null none` to be used where a `(ref null exact $Foo)` is expected.
304+
As a general rule, non-nullable exact references to abstract heap types are uninhabited.
313305

314306
When allocating types with custom descriptors,
315307
`struct.new` and `struct.new_default` take exact references to the descriptors

0 commit comments

Comments
 (0)