Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
b388d093
by Brian McKenna at 2026-07-18T17:51:50-04:00
4 changed files:
- + changelog.d/T27314.md
- compiler/GHC/HsToCore/Pmc/Solver.hs
- + testsuite/tests/pmcheck/should_compile/T27314.hs
- testsuite/tests/pmcheck/should_compile/all.T
Changes:
| 1 | +section: compiler
|
|
| 2 | +issues: #27314
|
|
| 3 | +mrs: !16118
|
|
| 4 | +synopsis:
|
|
| 5 | + Fix spurious ``-Wincomplete-uni-patterns`` warning under ``-finfo-table-map``.
|
|
| 6 | +description:
|
|
| 7 | + The pattern-match checker now ignores ticks when comparing scrutinees in
|
|
| 8 | + its CoreMap, so long-distance information is no longer lost across
|
|
| 9 | + function-application scrutinees because debug source annotations
|
|
| 10 | + (e.g. SourceNotes added by ``-finfo-table-map``) were inserted. |
| ... | ... | @@ -1000,8 +1000,9 @@ makeDictsCoherent (Case scrut bndr ty alts) |
| 1000 | 1000 | , let expr' = makeDictsCoherent expr ]
|
| 1001 | 1001 | makeDictsCoherent (Cast expr co)
|
| 1002 | 1002 | = Cast (makeDictsCoherent expr) co
|
| 1003 | -makeDictsCoherent (Tick tick expr)
|
|
| 1004 | - = Tick tick (makeDictsCoherent expr)
|
|
| 1003 | +makeDictsCoherent (Tick _tick expr)
|
|
| 1004 | + -- See Wrinkle (UD1) in Note [Unique dictionaries in the TmOracle CoreMap]
|
|
| 1005 | + = makeDictsCoherent expr
|
|
| 1005 | 1006 | makeDictsCoherent ty@(Type {})
|
| 1006 | 1007 | = ty
|
| 1007 | 1008 | makeDictsCoherent co@(Coercion {})
|
| ... | ... | @@ -1061,6 +1062,25 @@ In the end, replacing dictionaries with an error value in the pattern-match |
| 1061 | 1062 | checker was the most self-contained, although we might want to revisit once
|
| 1062 | 1063 | we implement a more robust approach to computing equality in the pattern-match
|
| 1063 | 1064 | checker (see #19272).
|
| 1065 | + |
|
| 1066 | +Wrinkle (UD1): ticks
|
|
| 1067 | +--------------------
|
|
| 1068 | +'makeDictsCoherent' also drops all ticks. The CoreMap key represents
|
|
| 1069 | +value-level equality, which ticks never affect.
|
|
| 1070 | + |
|
| 1071 | +Example (#27314): with -finfo-table-map every record-selector use site is
|
|
| 1072 | +wrapped in a 'SourceNote' carrying that site's span (see
|
|
| 1073 | +Note [Record-selector ticks] in GHC.HsToCore.Ticks). Given
|
|
| 1074 | + |
|
| 1075 | + data Box = Box { unBox :: Maybe Int }
|
|
| 1076 | + f b = case unBox b of
|
|
| 1077 | + Nothing -> 0
|
|
| 1078 | + Just _ -> let Just x = unBox b in x
|
|
| 1079 | + |
|
| 1080 | +the two `unBox b`s carry different SourceNote spans. Without tick stripping
|
|
| 1081 | +the CoreMap treats them as distinct expressions. Long-distance information
|
|
| 1082 | +from the outer `Just _` branch therefore never reaches the let-pattern, and
|
|
| 1083 | +`Just x = unBox b` is wrongly reported as non-exhaustive.
|
|
| 1064 | 1084 | -}
|
| 1065 | 1085 | |
| 1066 | 1086 | {- Note [The Pos/Neg invariant]
|
| 1 | +module T27314 where
|
|
| 2 | + |
|
| 3 | +data Box = Box { unBox :: Maybe Int }
|
|
| 4 | + |
|
| 5 | +f :: Box -> Int
|
|
| 6 | +f b = case unBox b of
|
|
| 7 | + Nothing -> 0
|
|
| 8 | + Just _ -> let Just x = unBox b in x |
| ... | ... | @@ -93,6 +93,14 @@ test('T21360', normal, compile, [overlapping_incomplete+'-Wincomplete-record-upd |
| 93 | 93 | test('T21360b', normal, compile, [overlapping_incomplete+'-Wincomplete-record-updates'])
|
| 94 | 94 | test('T23520', normal, compile, [overlapping_incomplete+'-Wincomplete-record-updates'])
|
| 95 | 95 | test('T25164', [extra_files(['T25164_aux.hs']), req_th], multimod_compile, ['T25164', '-v0'])
|
| 96 | +test(
|
|
| 97 | + 'T27314',
|
|
| 98 | + [ omit_ways(llvm_ways), # -finfo-table-map does not work with -fllvm (#26435)
|
|
| 99 | + when(js_arch(), skip) # javascript doesn't support -finfo-table-map yet and yields a warning we don't want to handle here
|
|
| 100 | + ],
|
|
| 101 | + compile,
|
|
| 102 | + ['-Wincomplete-uni-patterns -finfo-table-map']
|
|
| 103 | +)
|
|
| 96 | 104 | |
| 97 | 105 | # Other tests
|
| 98 | 106 | test('pmc001', [], compile, [overlapping_incomplete])
|