diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-07-18 13:51:53 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-07-18 13:51:53 -0400 |
commit | 1fc41d3274b5bf62f027aa6c7df57998db494938 (patch) | |
tree | 77e8e058104deb80ac5cce895331ec4459ecb922 /compiler | |
parent | 514c4a4741f3881672f1ccc1fe6d08a5d596bb87 (diff) | |
download | haskell-1fc41d3274b5bf62f027aa6c7df57998db494938.tar.gz |
Make okConIdOcc recognize unboxed tuples
Summary:
`okConIdOcc`, which validates that a type or constructor name is valid
for splicing using Template Haskell, has a special case for tuples, but
neglects to look for unboxed tuples, causing some sensible Template Haskell
code involving unboxed tuples to be rejected.
Fixes #12407.
Test Plan: make test TEST=T12407
Reviewers: austin, bgamari, hvr, goldfire
Reviewed By: goldfire
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2410
GHC Trac Issues: #12407
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/basicTypes/Lexeme.hs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler/basicTypes/Lexeme.hs b/compiler/basicTypes/Lexeme.hs index 22515c172c..ef5fa12dbd 100644 --- a/compiler/basicTypes/Lexeme.hs +++ b/compiler/basicTypes/Lexeme.hs @@ -154,18 +154,23 @@ okVarSymOcc str = all okSymChar str && -- starts with an acceptable letter? okConIdOcc :: String -> Bool okConIdOcc str = okIdOcc str || - is_tuple_name1 str + is_tuple_name1 True str || + -- Is it a boxed tuple... + is_tuple_name1 False str + -- ...or an unboxed tuple (Trac #12407)? where -- check for tuple name, starting at the beginning - is_tuple_name1 ('(' : rest) = is_tuple_name2 rest - is_tuple_name1 _ = False + is_tuple_name1 True ('(' : rest) = is_tuple_name2 True rest + is_tuple_name1 False ('(' : '#' : rest) = is_tuple_name2 False rest + is_tuple_name1 _ _ = False -- check for tuple tail - is_tuple_name2 ")" = True - is_tuple_name2 (',' : rest) = is_tuple_name2 rest - is_tuple_name2 (ws : rest) - | isSpace ws = is_tuple_name2 rest - is_tuple_name2 _ = False + is_tuple_name2 True ")" = True + is_tuple_name2 False "#)" = True + is_tuple_name2 boxed (',' : rest) = is_tuple_name2 boxed rest + is_tuple_name2 boxed (ws : rest) + | isSpace ws = is_tuple_name2 boxed rest + is_tuple_name2 _ _ = False -- | Is this an acceptable symbolic constructor name, assuming it -- starts with an acceptable character? |