Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sharedness bug in inhabitable type fuzzer #6807

Merged
merged 4 commits into from
Aug 6, 2024
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Aug 2, 2024

The code for collecting inhabitable types incorrectly considered shared,
non-nullable externrefs to be inhabitable, which disagreed with the code
for rewriting types to be inhabitable, which was correct, causing the
type fuzzer to report an error.

@tlively tlively requested a review from kripken August 2, 2024 23:13
Since there is only one unshared string heap type, the `isString()`
method did not do anything that could not be done as well with other,
more fundamental methods. Although using `isString` saved characters
compared with its replacement, that's not enough of a benefit to offset
the advantages of reducing redundant API surface and being more explicit
at callsites.

This would be NFC, but I updated many call sites of `isString` to handle
shared string types as well, or at least error more eagerly on them,
which may have changed observable behavior.
The HeapType API has functions like `isBasic()`, `isStruct()`,
`isSignature()`, etc. to test the classification of a heap type. Many
users have to call these functions in sequence and handle all or most of
the possible classifications. When we add a new kind of heap type,
finding and updating all these sites is a manual and error-prone
process.

To make adding new heap type kinds easier, introduce a new API that
returns an enum classifying the heap type. The enum can be used in
switch statements and the compiler's exhaustiveness checker will flag
use sites that need to be updated when we add a new kind of heap type.

This commit uses the new enum internally in the type system, but
follow-on commits will add new uses and convert uses of the existing
APIs to use `getKind` instead.
The code for collecting inhabitable types incorrectly considered shared,
non-nullable externrefs to be inhabitable, which disagreed with the code
for rewriting types to be inhabitable, which was correct, causing the
type fuzzer to report an error.
Base automatically changed from heaptype-getkind to main August 6, 2024 17:22
@tlively tlively merged commit 1c3578c into main Aug 6, 2024
13 checks passed
@tlively tlively deleted the fix-type-fuzzer-shared branch August 6, 2024 17:23
@gkdn gkdn mentioned this pull request Aug 31, 2024
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