summaryrefslogtreecommitdiff
path: root/compiler/GHC/ByteCode
diff options
context:
space:
mode:
authorRoland Senn <rsx@bluewin.ch>2021-05-27 16:04:13 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-02 04:39:23 -0400
commitfcd124d5c7c1c4ea8488587f65112b7a66b7da83 (patch)
tree00d87b0161e2a8245d057ff98cbebc29dd6cc46f /compiler/GHC/ByteCode
parent6b6c4b9ab0f773011a04c19f3cd5131a1aab2a41 (diff)
downloadhaskell-fcd124d5c7c1c4ea8488587f65112b7a66b7da83.tar.gz
Allow primops in a :print (and friends) command. Fix #19394
* For primops from `GHC.Prim` lookup the HValues in `GHC.PrimopWrappers`. * Add short error messages if a user tries to use a *Non-Id* value or a `pseudoop` in a `:print`, `:sprint` or `force`command. * Add additional test cases for `Magic Ids`.
Diffstat (limited to 'compiler/GHC/ByteCode')
-rw-r--r--compiler/GHC/ByteCode/Linker.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/GHC/ByteCode/Linker.hs b/compiler/GHC/ByteCode/Linker.hs
index 3e36e41073..c9339317d2 100644
--- a/compiler/GHC/ByteCode/Linker.hs
+++ b/compiler/GHC/ByteCode/Linker.hs
@@ -28,6 +28,7 @@ import GHCi.ResolvedBCO
import GHCi.BreakArray
import GHC.Builtin.PrimOps
+import GHC.Builtin.Names
import GHC.Unit.Types
import GHC.Unit.Module.Name
@@ -184,7 +185,11 @@ nameToCLabel :: Name -> String -> FastString
nameToCLabel n suffix = mkFastString label
where
encodeZ = zString . zEncodeFS
- (Module pkgKey modName) = assert (isExternalName n) $ nameModule n
+ (Module pkgKey modName) = assert (isExternalName n) $ case nameModule n of
+ -- Primops are exported from GHC.Prim, their HValues live in GHC.PrimopWrappers
+ -- See Note [Primop wrappers] in GHC.Builtin.PrimOps.
+ mod | mod == gHC_PRIM -> gHC_PRIMOPWRAPPERS
+ mod -> mod
packagePart = encodeZ (unitFS pkgKey)
modulePart = encodeZ (moduleNameFS modName)
occPart = encodeZ (occNameFS (nameOccName n))