diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-02-15 11:09:34 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-16 16:39:51 -0500 |
commit | a04179e74bf18837236fea02040438a2c29c8d56 (patch) | |
tree | b7424a559720f586540fb2436776ec93ca452f8d /testsuite | |
parent | 7686f9f80d31d724b2e84b229de5efffbe6e45b4 (diff) | |
download | haskell-a04179e74bf18837236fea02040438a2c29c8d56.tar.gz |
Parse symbolic names in ANN type correctly with otycon
This adds a new `otycon` production to the parser that allows for type
constructor names that are either alphanumeric (`tycon`) or symbolic
(`tyconsym`), where the latter must be parenthesized appropriately.
`otycon` is much like the existing `oqtycon` production, except that it does
not permit qualified names. The parser now uses `otycon` to parse type
constructor names in `ANN type` declarations, which fixes #19374.
To make sure that all of this works, I added three test cases:
* `should_compile/T19374a`: the original test case from #19374
* `should_fail/T19374b`: a test that makes sure that an `ANN` with a qualified
name fails to parse
* `should_fail/T19374c`: a test that makes sure that an `ANN type` with a
qualified name fails to parse
Diffstat (limited to 'testsuite')
7 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/annotations/should_compile/T19374a.hs b/testsuite/tests/annotations/should_compile/T19374a.hs new file mode 100644 index 0000000000..95a1aa8baf --- /dev/null +++ b/testsuite/tests/annotations/should_compile/T19374a.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeOperators #-} +module T19374 where + +(%%) :: [a] -> [a] -> [a] +(%%) = (++) +{-# ANN (%%) "This is an annotation" #-} + +data (%%%) +{-# ANN type (%%%) "This is also an annotation" #-} diff --git a/testsuite/tests/annotations/should_compile/all.T b/testsuite/tests/annotations/should_compile/all.T index be81c4fc19..8861d1baa3 100644 --- a/testsuite/tests/annotations/should_compile/all.T +++ b/testsuite/tests/annotations/should_compile/all.T @@ -4,6 +4,7 @@ # now, just disable the profiling ways. test('ann01', [req_interp, omit_ways(prof_ways)], compile, ['-v0']) test('T14129', [req_interp, omit_ways(prof_ways)], compile, ['-v0']) +test('T19374a', [req_interp, omit_ways(prof_ways)], compile, ['-v0']) """" Helpful things to C+P: diff --git a/testsuite/tests/annotations/should_fail/T19374b.hs b/testsuite/tests/annotations/should_fail/T19374b.hs new file mode 100644 index 0000000000..1ee5c6a9e3 --- /dev/null +++ b/testsuite/tests/annotations/should_fail/T19374b.hs @@ -0,0 +1,5 @@ +module T19347b where + +(%%) :: [a] -> [a] -> [a] +(%%) = (++) +{-# ANN (T19347b.%%) "This is an annotation" #-} diff --git a/testsuite/tests/annotations/should_fail/T19374b.stderr b/testsuite/tests/annotations/should_fail/T19374b.stderr new file mode 100644 index 0000000000..0d44c4c2e3 --- /dev/null +++ b/testsuite/tests/annotations/should_fail/T19374b.stderr @@ -0,0 +1,2 @@ + +T19374b.hs:5:10: error: parse error on input ‘T19347b.%%’ diff --git a/testsuite/tests/annotations/should_fail/T19374c.hs b/testsuite/tests/annotations/should_fail/T19374c.hs new file mode 100644 index 0000000000..d28af8049d --- /dev/null +++ b/testsuite/tests/annotations/should_fail/T19374c.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeOperators #-} +module T19347c where + +data (%%%) +{-# ANN type (T19347c.%%%) "This is also an annotation" #-} diff --git a/testsuite/tests/annotations/should_fail/T19374c.stderr b/testsuite/tests/annotations/should_fail/T19374c.stderr new file mode 100644 index 0000000000..55700d006a --- /dev/null +++ b/testsuite/tests/annotations/should_fail/T19374c.stderr @@ -0,0 +1,2 @@ + +T19374c.hs:5:15: error: parse error on input ‘T19347c.%%%’ diff --git a/testsuite/tests/annotations/should_fail/all.T b/testsuite/tests/annotations/should_fail/all.T index e15cd35322..1f160a0d77 100644 --- a/testsuite/tests/annotations/should_fail/all.T +++ b/testsuite/tests/annotations/should_fail/all.T @@ -16,6 +16,8 @@ test('annfail11', normal, compile_fail, ['']) test('annfail12', req_interp, compile_fail, ['-v0']) test('annfail13', normal, compile_fail, ['']) test('T10826', normal, compile_fail, ['']) +test('T19374b', normal, compile_fail, ['']) +test('T19374c', normal, compile_fail, ['']) """" Helpful things to C+P: |