summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorLawton Nichols <lawtonnichols@gmail.com>2022-11-16 14:12:14 -0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-19 03:22:14 -0500
commitb0ac38133767a8ca7de63112f39436241ff435a0 (patch)
tree43b377daf1d056699878f37e92d92e37dcf33cc1 /testsuite
parent37cfe3c0f4fb16189bbe3bb735f758cd6e3d9157 (diff)
downloadhaskell-b0ac38133767a8ca7de63112f39436241ff435a0.tar.gz
Give better errors for code corrupted by Unicode smart quotes (#21843)
Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/parser/should_fail/T21843a.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T21843a.stderr4
-rw-r--r--testsuite/tests/parser/should_fail/T21843b.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T21843b.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/T21843c.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T21843c.stderr6
-rw-r--r--testsuite/tests/parser/should_fail/T21843d.hs4
-rw-r--r--testsuite/tests/parser/should_fail/T21843d.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/T21843e.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T21843e.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/T21843f.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T21843f.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/all.T6
13 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/tests/parser/should_fail/T21843a.hs b/testsuite/tests/parser/should_fail/T21843a.hs
new file mode 100644
index 0000000000..1b56d86553
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843a.hs
@@ -0,0 +1,3 @@
+module UnicodeSmartQuotes where
+
+badString = “hello”
diff --git a/testsuite/tests/parser/should_fail/T21843a.stderr b/testsuite/tests/parser/should_fail/T21843a.stderr
new file mode 100644
index 0000000000..11ad47d94a
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843a.stderr
@@ -0,0 +1,4 @@
+
+T21843a.hs:3:13: [GHC-31623]
+ Unicode character '“' ('/8220') looks like '"' (Quotation Mark), but it is not
+
diff --git a/testsuite/tests/parser/should_fail/T21843b.hs b/testsuite/tests/parser/should_fail/T21843b.hs
new file mode 100644
index 0000000000..57bf9e81d5
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843b.hs
@@ -0,0 +1,3 @@
+module UnicodeSmartQuotes where
+
+badChar = ‘x’
diff --git a/testsuite/tests/parser/should_fail/T21843b.stderr b/testsuite/tests/parser/should_fail/T21843b.stderr
new file mode 100644
index 0000000000..34c531c3f8
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843b.stderr
@@ -0,0 +1,3 @@
+
+T21843b.hs:3:11: [GHC-31623]
+ Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not
diff --git a/testsuite/tests/parser/should_fail/T21843c.hs b/testsuite/tests/parser/should_fail/T21843c.hs
new file mode 100644
index 0000000000..d3aa809185
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843c.hs
@@ -0,0 +1,3 @@
+module UnicodeSmartQuotes where
+
+badString = "hello”
diff --git a/testsuite/tests/parser/should_fail/T21843c.stderr b/testsuite/tests/parser/should_fail/T21843c.stderr
new file mode 100644
index 0000000000..54146a42eb
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843c.stderr
@@ -0,0 +1,6 @@
+
+T21843c.hs:3:19: [GHC-31623]
+ Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not
+
+T21843c.hs:3:20: [GHC-21231]
+ lexical error in string/character literal at character '/n'
diff --git a/testsuite/tests/parser/should_fail/T21843d.hs b/testsuite/tests/parser/should_fail/T21843d.hs
new file mode 100644
index 0000000000..440967ce6c
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843d.hs
@@ -0,0 +1,4 @@
+module UnicodeSmartQuotes where
+
+badChar = 'x’
+
diff --git a/testsuite/tests/parser/should_fail/T21843d.stderr b/testsuite/tests/parser/should_fail/T21843d.stderr
new file mode 100644
index 0000000000..4ee47ed8ef
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843d.stderr
@@ -0,0 +1,3 @@
+
+T21843d.hs:3:13: [GHC-31623]
+ Unicode character '’' ('/8217') looks like ''' (Single Quote), but it is not
diff --git a/testsuite/tests/parser/should_fail/T21843e.hs b/testsuite/tests/parser/should_fail/T21843e.hs
new file mode 100644
index 0000000000..5fd3b9614a
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843e.hs
@@ -0,0 +1,3 @@
+module UnicodeSmartQuotes where
+
+badString = "\”"
diff --git a/testsuite/tests/parser/should_fail/T21843e.stderr b/testsuite/tests/parser/should_fail/T21843e.stderr
new file mode 100644
index 0000000000..c39d573b87
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843e.stderr
@@ -0,0 +1,3 @@
+
+T21843e.hs:3:15: [GHC-31623]
+ Unicode character '”' ('/8221') looks like '"' (Quotation Mark), but it is not
diff --git a/testsuite/tests/parser/should_fail/T21843f.hs b/testsuite/tests/parser/should_fail/T21843f.hs
new file mode 100644
index 0000000000..884ff11d71
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843f.hs
@@ -0,0 +1,3 @@
+module UnicodeSmartQuotes where
+
+badChar = '\‘'
diff --git a/testsuite/tests/parser/should_fail/T21843f.stderr b/testsuite/tests/parser/should_fail/T21843f.stderr
new file mode 100644
index 0000000000..198917937a
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T21843f.stderr
@@ -0,0 +1,3 @@
+
+T21843f.hs:3:13: [GHC-31623]
+ Unicode character '‘' ('/8216') looks like ''' (Single Quote), but it is not
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index 8713d91f2b..9dc87514c5 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -209,3 +209,9 @@ test('T20385A', normal, compile_fail, [''])
test('T20385B', normal, compile_fail, [''])
test('T16999', normal, compile_fail, [''])
test('T22070', normal, compile_fail, [''])
+test('T21843a', normal, compile_fail, [''])
+test('T21843b', normal, compile_fail, [''])
+test('T21843c', normal, compile_fail, [''])
+test('T21843d', normal, compile_fail, [''])
+test('T21843e', normal, compile_fail, [''])
+test('T21843f', normal, compile_fail, [''])