diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2022-12-07 05:38:40 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-12-08 22:50:21 -0500 |
commit | b0cc2fcfc485da772c5ffef1b625af9e7ae73129 (patch) | |
tree | 95ac4a78e5d33afd049775c58e1fe0053b2fb360 /testsuite | |
parent | 3609340743c1b25fdfd0e18b1670dac54c8d8623 (diff) | |
download | haskell-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 'testsuite')
-rw-r--r-- | testsuite/tests/ghc-api/annotations-literals/literals.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations-literals/parsed.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/th/T14681.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/th/T14681.stderr | 14 |
4 files changed, 18 insertions, 5 deletions
diff --git a/testsuite/tests/ghc-api/annotations-literals/literals.stdout b/testsuite/tests/ghc-api/annotations-literals/literals.stdout index eb87a80162..46f5643ff3 100644 --- a/testsuite/tests/ghc-api/annotations-literals/literals.stdout +++ b/testsuite/tests/ghc-api/annotations-literals/literals.stdout @@ -98,7 +98,7 @@ (LiteralsTest.hs:19:11,ITequal,[=]), -(LiteralsTest.hs:19:13-19,ITprimchar (SourceText "'\\x41'") 'A',['\x41'#]), +(LiteralsTest.hs:19:13-19,ITprimchar (SourceText "'\\x41'#") 'A',['\x41'#]), (LiteralsTest.hs:20:5,ITsemi,[]), diff --git a/testsuite/tests/ghc-api/annotations-literals/parsed.stdout b/testsuite/tests/ghc-api/annotations-literals/parsed.stdout index 12c0c7192c..4e50d78a73 100644 --- a/testsuite/tests/ghc-api/annotations-literals/parsed.stdout +++ b/testsuite/tests/ghc-api/annotations-literals/parsed.stdout @@ -2,7 +2,7 @@ HsIntegral [0003] 3 HsIntegral [0x04] 4 HsString ["\x20"] " " HsChar ['\x20'] ' ' -HsCharPrim ['\x41'] 'A' +HsCharPrim ['\x41'#] 'A' HsIntPrim [0004#] 4 HsWordPrim [005##] 5 HsIntegral [1] 1 diff --git a/testsuite/tests/th/T14681.hs b/testsuite/tests/th/T14681.hs index 341a1a66b1..a83e9fb713 100644 --- a/testsuite/tests/th/T14681.hs +++ b/testsuite/tests/th/T14681.hs @@ -1,9 +1,12 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TemplateHaskell, MagicHash #-} module T14681 where import Data.Functor.Identity import Language.Haskell.TH +import GHC.Exts $([d| f = \(Identity x) -> x |]) $([d| g = $(pure $ VarE '(+) `AppE` LitE (IntegerL (-1)) `AppE` (LitE (IntegerL (-1)))) |]) +$([d| h _ = $(pure $ VarE '(+#) `AppE` LitE (IntPrimL (-1)) + `AppE` (LitE (IntPrimL (-1)))) |]) diff --git a/testsuite/tests/th/T14681.stderr b/testsuite/tests/th/T14681.stderr index f9838186ca..8be521ff01 100644 --- a/testsuite/tests/th/T14681.stderr +++ b/testsuite/tests/th/T14681.stderr @@ -1,6 +1,6 @@ -T14681.hs:7:2-32: Splicing declarations +T14681.hs:8:2-32: Splicing declarations [d| f = \ (Identity x) -> x |] ======> f = \ (Identity x) -> x -T14681.hs:(8,2)-(9,63): Splicing declarations +T14681.hs:(9,2)-(10,63): Splicing declarations [d| g = $(pure $ VarE '(+) `AppE` LitE (IntegerL (- 1)) `AppE` (LitE (IntegerL (- 1)))) |] @@ -9,3 +9,13 @@ T14681.hs:(8,2)-(9,63): Splicing declarations `AppE` (LitE (IntegerL (- 1)))>] ======> g = (+) (-1) (-1) +T14681.hs:(11,2)-(12,66): Splicing declarations + [d| h _ + = $(pure + $ VarE '(+#) `AppE` LitE (IntPrimL (- 1)) + `AppE` (LitE (IntPrimL (- 1)))) |] + pending(rn) [<spn, pure + $ VarE '(+#) `AppE` LitE (IntPrimL (- 1)) + `AppE` (LitE (IntPrimL (- 1)))>] + ======> + h _ = (+#) -1# -1# |