diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-12-22 10:59:16 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-12-24 00:42:51 -0500 |
commit | 6d62f6bfbb5a86131e7cbc30993f3fa510d8b3ab (patch) | |
tree | e888f791533511ce762e8768ba4790772c3b7ce7 /testsuite/tests | |
parent | f42ba88fd32f1def7dcf02f0a2227b453bf5971c (diff) | |
download | haskell-6d62f6bfbb5a86131e7cbc30993f3fa510d8b3ab.tar.gz |
Store RdrName rather than OccName in Holes
In #20472 it was pointed out that you couldn't defer out of scope but
the implementation collapsed a RdrName into an OccName to stuff it into
a Hole. This leads to the error message for a deferred qualified name
dropping the qualification which affects the quality of the error
message.
This commit adds a bit more structure to a hole, so a hole can replace a
RdrName without losing information about what that RdrName was. This is
important when printing error messages.
I also added a test which checks the Template Haskell deferral of out of
scope qualified names works properly.
Fixes #22130
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/perf/compiler/hard_hole_fits.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/plugins/hole-fit-plugin/HoleFitPlugin.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/quotes/T20472_quotes.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/quotes/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20472.stderr | 6 |
5 files changed, 13 insertions, 4 deletions
diff --git a/testsuite/tests/perf/compiler/hard_hole_fits.stderr b/testsuite/tests/perf/compiler/hard_hole_fits.stderr index fcdde2ee2d..9d4e926892 100644 --- a/testsuite/tests/perf/compiler/hard_hole_fits.stderr +++ b/testsuite/tests/perf/compiler/hard_hole_fits.stderr @@ -22,7 +22,7 @@ hard_hole_fits.hs:15:32: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: Int • In an equation for ‘testMe’: testMe (HsUnboundVar xuv uv) = _ • Relevant bindings include - uv :: GHC.Types.Name.Occurrence.OccName + uv :: GHC.Types.Name.Reader.RdrName (bound at hard_hole_fits.hs:15:26) xuv :: Language.Haskell.Syntax.Extension.XUnboundVar GhcPs (bound at hard_hole_fits.hs:15:22) diff --git a/testsuite/tests/plugins/hole-fit-plugin/HoleFitPlugin.hs b/testsuite/tests/plugins/hole-fit-plugin/HoleFitPlugin.hs index e9f504d92d..3e8cd06a52 100644 --- a/testsuite/tests/plugins/hole-fit-plugin/HoleFitPlugin.hs +++ b/testsuite/tests/plugins/hole-fit-plugin/HoleFitPlugin.hs @@ -34,7 +34,7 @@ fromModule _ = [] toHoleFitCommand :: TypedHole -> String -> Maybe String toHoleFitCommand (TypedHole {th_hole = Just (Hole { hole_occ = h })}) str - = stripPrefix ("_" <> str) $ occNameString h + = stripPrefix ("_" <> str) $ occNameString (occName h) toHoleFitCommand _ _ = Nothing diff --git a/testsuite/tests/quotes/T20472_quotes.hs b/testsuite/tests/quotes/T20472_quotes.hs new file mode 100644 index 0000000000..faebf59a21 --- /dev/null +++ b/testsuite/tests/quotes/T20472_quotes.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE NoMonomorphismRestriction #-} +{-# OPTIONS_GHC -fdefer-out-of-scope-variables #-} +module T20472_quotes where + +foo = [| Prelude.a |] diff --git a/testsuite/tests/quotes/all.T b/testsuite/tests/quotes/all.T index ba580ccaf4..4fa5d13d55 100644 --- a/testsuite/tests/quotes/all.T +++ b/testsuite/tests/quotes/all.T @@ -41,3 +41,4 @@ test('TH_double_splice', normal, compile_fail, ['']) test('T20688', normal, compile, ['-Wimplicit-lift -Werror']) test('T20893', normal, compile_and_run, ['']) test('T21619', normal, compile, ['']) +test('T20472_quotes', normal, compile, ['']) diff --git a/testsuite/tests/rename/should_compile/T20472.stderr b/testsuite/tests/rename/should_compile/T20472.stderr index c1b18c4951..11e4e830d9 100644 --- a/testsuite/tests/rename/should_compile/T20472.stderr +++ b/testsuite/tests/rename/should_compile/T20472.stderr @@ -3,7 +3,9 @@ T20472.hs:5:5: warning: [GHC-88464] [-Wdeferred-out-of-scope-variables (in -Wdef Variable not in scope: nonexistent T20472.hs:6:5: warning: [GHC-88464] [-Wdeferred-out-of-scope-variables (in -Wdefault)] - Variable not in scope: nonexistent + Variable not in scope: Prelude.nonexistent + NB: the module ‘Prelude’ does not export ‘nonexistent’. T20472.hs:8:5: warning: [GHC-88464] [-Wdeferred-out-of-scope-variables (in -Wdefault)] - Variable not in scope: x + Variable not in scope: Nonexistent.x + NB: no module named ‘Nonexistent’ is imported. |