summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupert Horlick <ruperthorlick@gmail.com>2017-03-06 13:44:40 -0500
committerBen Gamari <ben@smart-cactus.org>2017-03-06 17:23:02 -0500
commit6177c0d8bdc6f5c0675b2eace592620abb658787 (patch)
treeb798c7cc95a3c6e6f77a9e9cef11a1332504ed3e
parentf57bd2ae8fc787f14aeafa3f2f7ded253456528c (diff)
downloadhaskell-6177c0d8bdc6f5c0675b2eace592620abb658787.tar.gz
Disallow unboxed string literals in patterns (#13260)
Signed-off-by: Rupert Horlick <ruperthorlick@gmail.com> Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3286
-rw-r--r--compiler/parser/RdrHsSyn.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T13260.hs7
-rw-r--r--testsuite/tests/parser/should_fail/T13260.stderr4
-rw-r--r--testsuite/tests/parser/should_fail/all.T1
4 files changed, 15 insertions, 0 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs
index 2c63c428b6..e06c7e36c0 100644
--- a/compiler/parser/RdrHsSyn.hs
+++ b/compiler/parser/RdrHsSyn.hs
@@ -829,6 +829,9 @@ checkAPat msg loc e0 = do
case e0 of
EWildPat -> return (WildPat placeHolderType)
HsVar x -> return (VarPat x)
+ HsLit (HsStringPrim _ _) -- (#13260)
+ -> parseErrorSDoc loc (text "Illegal unboxed string literal in pattern:" $$ ppr e0)
+
HsLit l -> return (LitPat l)
-- Overloaded numeric patterns (e.g. f 0 x = x)
diff --git a/testsuite/tests/parser/should_fail/T13260.hs b/testsuite/tests/parser/should_fail/T13260.hs
new file mode 100644
index 0000000000..b0e1f97529
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T13260.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE MagicHash #-}
+
+module T13260 where
+
+ g y = case y of
+ "a"# -> True
+ _ -> False
diff --git a/testsuite/tests/parser/should_fail/T13260.stderr b/testsuite/tests/parser/should_fail/T13260.stderr
new file mode 100644
index 0000000000..05e99d60ee
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T13260.stderr
@@ -0,0 +1,4 @@
+
+T13260.hs:6:5: error:
+ Illegal unboxed string literal in pattern:
+ "a"#
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index b3efb5c193..1496feca4a 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -96,3 +96,4 @@ test('T10498b', normal, compile_fail, [''])
test('T12051', normal, compile_fail, [''])
test('T12429', normal, compile_fail, [''])
test('T12811', normal, compile_fail, [''])
+test('T13260', normal, compile_fail, [''])