Simon Jakobi pushed to branch wip/sjakobi/T27459 at Glasgow Haskell Compiler / GHC
Commits:
-
b85976c9
by Simon Jakobi at 2026-08-15T13:27:20+02:00
-
480e2cdf
by Simon Jakobi at 2026-08-15T14:20:28+02:00
4 changed files:
- compiler/GHC/Tc/Errors/Ppr.hs
- + testsuite/tests/determinism/determ025/A.hs
- + testsuite/tests/determinism/determ025/Makefile
- + testsuite/tests/determinism/determ025/all.T
Changes:
| ... | ... | @@ -4999,10 +4999,12 @@ potentials_msg_with_options |
| 4999 | 4999 | n_show_matches = 3
|
| 5000 | 5000 | n_show_unifiers = 2
|
| 5001 | 5001 | |
| 5002 | - (in_scope_matches, not_in_scope_matches) = partition inst_in_scope matches
|
|
| 5003 | - (in_scope_unifiers, not_in_scope_unifiers) = partition inst_in_scope unifiers
|
|
| 5004 | - sorted_matches = sortBy fuzzyClsInstCmp in_scope_matches
|
|
| 5005 | - sorted_unifiers = sortBy fuzzyClsInstCmp in_scope_unifiers
|
|
| 5002 | + -- Sort before partitioning so that the out-of-scope lists are also
|
|
| 5003 | + -- shown in a deterministic order (#27459).
|
|
| 5004 | + (sorted_matches, not_in_scope_matches)
|
|
| 5005 | + = partition inst_in_scope (sortBy fuzzyClsInstCmp matches)
|
|
| 5006 | + (sorted_unifiers, not_in_scope_unifiers)
|
|
| 5007 | + = partition inst_in_scope (sortBy fuzzyClsInstCmp unifiers)
|
|
| 5006 | 5008 | (show_these_matches, show_these_unifiers)
|
| 5007 | 5009 | | show_all_potentials = (sorted_matches, sorted_unifiers)
|
| 5008 | 5010 | | otherwise = (take n_show_matches sorted_matches
|
| 1 | +module A where
|
|
| 2 | + |
|
| 3 | +-- An ambiguity error whose message lists potential instances, both in-scope
|
|
| 4 | +-- and (via the instance-only imports) involving out-of-scope types.
|
|
| 5 | + |
|
| 6 | +import Data.Functor.Const ()
|
|
| 7 | +import Data.Functor.Identity ()
|
|
| 8 | +import Data.Monoid ()
|
|
| 9 | +import Data.Proxy ()
|
|
| 10 | +import Data.Ord ()
|
|
| 11 | + |
|
| 12 | +v :: Int
|
|
| 13 | +v = foldr (+) 0 (pure 21) |
| 1 | +TOP=../../..
|
|
| 2 | +include $(TOP)/mk/boilerplate.mk
|
|
| 3 | +include $(TOP)/mk/test.mk
|
|
| 4 | + |
|
| 5 | +# Check that error messages don't depend on the order of Uniques (#27459):
|
|
| 6 | +# compile a module producing an ambiguity error with two unique supplies
|
|
| 7 | +# and compare the errors.
|
|
| 8 | +determ025:
|
|
| 9 | + $(RM) A.hi A.o
|
|
| 10 | + -'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -dinitial-unique=0 -dunique-increment=1 A.hs 2> A.err.normal
|
|
| 11 | + $(RM) A.hi A.o
|
|
| 12 | + -'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -dinitial-unique=16777215 -dunique-increment=-1 A.hs 2> A.err.reversed
|
|
| 13 | + diff A.err.normal A.err.reversed
|
|
| 14 | + $(RM) A.hi A.o
|
|
| 15 | + -'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -fprint-potential-instances -dinitial-unique=0 -dunique-increment=1 A.hs 2> A.err.all.normal
|
|
| 16 | + $(RM) A.hi A.o
|
|
| 17 | + -'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -fprint-potential-instances -dinitial-unique=16777215 -dunique-increment=-1 A.hs 2> A.err.all.reversed
|
|
| 18 | + diff A.err.all.normal A.err.all.reversed |
| 1 | +test('determ025',
|
|
| 2 | + [extra_files(['A.hs'])],
|
|
| 3 | + makefile_test, ['determ025']) |