diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-03-08 23:36:26 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-03-09 08:47:12 +0300 |
commit | 518657a400b014cc85c7428f3ad0f2bee75e7f77 (patch) | |
tree | 5477070ca31bb227bfcec1118c23fdcf637208f3 | |
parent | bfa862503a9f8b2e8a61b9499d2cc3be789779fd (diff) | |
download | haskell-wip/t19504.tar.gz |
Location for tuple section pattern error (#19504)wip/t19504
This fixes a regression that led to loss of location information
in error messages about the use of tuple sections in patterns.
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/T19504.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/T19504.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/all.T | 1 |
4 files changed, 9 insertions, 1 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 234df36be9..9ab0ef2370 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -2670,7 +2670,9 @@ mkSumOrTuplePat l boxity (Tuple ps) = do return $ L l (PatBuilderPat (TuplePat noExtField ps' boxity)) where toTupPat :: Located (Maybe (Located (PatBuilder GhcPs))) -> PV (LPat GhcPs) - toTupPat (L l p) = case p of + -- Ignore the element location so that the error message refers to the + -- entire tuple. See #19504 (and the discussion) for details. + toTupPat (L _ p) = case p of Nothing -> addFatalError $ PsError PsErrTupleSectionInPat [] l Just p' -> checkLPat p' diff --git a/testsuite/tests/parser/should_fail/T19504.hs b/testsuite/tests/parser/should_fail/T19504.hs new file mode 100644 index 0000000000..033f13e4db --- /dev/null +++ b/testsuite/tests/parser/should_fail/T19504.hs @@ -0,0 +1,3 @@ +module T19504 where + +error_notLocated = (\ (0, ) -> (0, undefined)) diff --git a/testsuite/tests/parser/should_fail/T19504.stderr b/testsuite/tests/parser/should_fail/T19504.stderr new file mode 100644 index 0000000000..9d37ba22a0 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T19504.stderr @@ -0,0 +1,2 @@ + +T19504.hs:3:23: error: Tuple section in pattern context diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index 21d66337e9..49a298c93f 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -189,3 +189,4 @@ test('RecordDotSyntaxFail10', normal, compile_fail, ['']) test('RecordDotSyntaxFail11', normal, compile_fail, ['']) test('RecordDotSyntaxFail12', normal, compile_fail, ['']) test('RecordDotSyntaxFail13', normal, compile_fail, ['']) +test('T19504', normal, compile_fail, ['']) |