summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/Lexer.x
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-12-07 05:38:40 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-08 22:50:21 -0500
commitb0cc2fcfc485da772c5ffef1b625af9e7ae73129 (patch)
tree95ac4a78e5d33afd049775c58e1fe0053b2fb360 /compiler/GHC/Parser/Lexer.x
parent3609340743c1b25fdfd0e18b1670dac54c8d8623 (diff)
downloadhaskell-b0cc2fcfc485da772c5ffef1b625af9e7ae73129.tar.gz
Fixes around primitive literals
* The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681.
Diffstat (limited to 'compiler/GHC/Parser/Lexer.x')
-rw-r--r--compiler/GHC/Parser/Lexer.x6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/GHC/Parser/Lexer.x b/compiler/GHC/Parser/Lexer.x
index 8b3c4eccea..a116aec66c 100644
--- a/compiler/GHC/Parser/Lexer.x
+++ b/compiler/GHC/Parser/Lexer.x
@@ -2172,10 +2172,12 @@ finish_char_tok buf loc ch -- We've already seen the closing quote
let src = lexemeToString buf (cur bufEnd - cur buf)
if magicHash then do
case alexGetChar' i of
- Just ('#',i@(AI end _)) -> do
+ Just ('#',i@(AI end bufEnd')) -> do
setInput i
+ -- Include the trailing # in SourceText
+ let src' = lexemeToString buf (cur bufEnd' - cur buf)
return (L (mkPsSpan loc end)
- (ITprimchar (SourceText src) ch))
+ (ITprimchar (SourceText src') ch))
_other ->
return (L (mkPsSpan loc end)
(ITchar (SourceText src) ch))