Propagate long distance info to guarded let binds
This commit ensures that we propagate the enclosing long distance information to let bindings inside guards, in order to get accurate pattern-match checking warnings, in particular incomplete record selector warnings. Example: data D = K0 | K1 { fld :: Int } f :: D -> Int f d@(K1 {}) | let i = fld d = i f _ = 3 We now correctly recognise that the field selector 'fld' cannot fail, due to the outer pattern match which guarantees that the value 'd' has the field 'fld'. Fixes #25749
Showing
- compiler/GHC/HsToCore/GuardedRHSs.hs 26 additions, 18 deletionscompiler/GHC/HsToCore/GuardedRHSs.hs
- testsuite/tests/pmcheck/should_compile/T25749.hs 18 additions, 0 deletionstestsuite/tests/pmcheck/should_compile/T25749.hs
- testsuite/tests/pmcheck/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/pmcheck/should_compile/all.T
Please register or sign in to comment