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 passedSome
type explicitly, or passed the parent's expected type in a self-recursive call.Therefore, by induction,
expected_ty
is neverNone
. 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 neverNone
, 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.
jameysharp requested elliottt for a review on PR #6144.
jameysharp requested wasmtime-compiler-reviewers for a review on PR #6144.
fitzgen submitted PR review.
elliottt submitted PR review.
jameysharp merged PR #6144.
Last updated: Nov 22 2024 at 17:03 UTC