Skip to content

typecheck: Account for -XStrict in irrefutability check

Ben Gamari requested to merge wip/T19027 into master

When -XStrict is enabled the rules for irrefutability are slightly modified. Specifically, the pattern in a program like

do ~(Just hi) <- expr

cannot be considered irrefutable. The ~ here merely disables the bang that -XStrict would usually apply, rendering the program equivalent to the following without -XStrict

do Just hi <- expr

To achieve make this pattern irrefutable with -XStrict the user would rather need to write

do ~(~(Just hi)) <- expr

Failing to account for this resulted in #19027 (closed). To fix this isIrrefutableHsPat takes care to check for two the irrefutability of the inner pattern when it encounters a LazyPat and -XStrict is enabled.

Merge request reports