Stream: git-wasmtime

Topic: wasmtime / PR #6144 ISLE: pattern type is always known


view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 00:24):

jameysharp opened PR #6144 from jameysharp:isle-pattern-types to bytecodealliance:main:

While type-checking the AST for a pattern, ISLE was passing in an Option<TypeId> for the expected result type of the pattern. However, at every call we either passed Some type explicitly, or passed the parent's expected type in a self-recursive call.

Therefore, by induction, expected_ty is never None. So this PR unwraps the type everywhere. That in turn shows that a bunch of error messages were unreachable, so this deletes a bunch of error-handling code.

In addition, this function returned the type it computed for the sub-pattern, but that information is already available in the sub-pattern itself. Not only that but the type should always be equal to expected_ty; when it isn't, we've reported a type error and are just trying to check for more errors.

Most callers ignored the returned type but in some cases we used it to try to avoid emitting useless error messages. I've preserved that behavior for bind-patterns.

For and-patterns, the returned type looked like it was being used, but because expected_ty was never None, the fallback of "fill in with the sub-pattern's type" never fired. So I've deleted that fallback.

Finally, this reverts #4915 (9d99eff6f90522a838551326e651bb6b660ca624) which was introduced to flatten nested and-patterns, to simplify overlap checking. However, the visitor trait used by trie_again effectively flattens and-patterns anyway, so the current representation used for overlap checking doesn't need this any more.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 00:24):

jameysharp requested elliottt for a review on PR #6144.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 00:24):

jameysharp requested wasmtime-compiler-reviewers for a review on PR #6144.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 15:29):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 15:37):

elliottt submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 16:53):

jameysharp merged PR #6144.


Last updated: Nov 22 2024 at 17:03 UTC