Skip to content

let x = ... and x = ... are not the same in GHCi

With #7253 (closed) we implemented support for x = ... in GHCi which is supposed to do the same thing as let x = ..., but they're currently different, as observed in #16089 (closed), #15721 (closed), and probably in other tickets. Here's a reproducer:

~ $ ghci -ddump-bcos
GHCi, version 8.4.4: http://www.haskell.org/ghc/  :? for help

...

λ:1> let x = [True,False]

==================== Proto-BCOs ====================
ProtoBCO ExprTopLevel_E0#0 []:
   let sat_s1vF = ... in ...
   bitmap:  0 []
   PUSH_G   GHC.Types.[]
   PUSH_G   GHC.Types.False
   PACK     : 2
   PUSH_L   0
   PUSH_G   GHC.Types.True
   PACK     : 2
   PUSH_G   GHC.Types.[]
   PUSH_L   1
   PACK     : 2
   PUSH_L   0
   PUSH_APPLY_P
   PUSH_G   GHC.Base.returnIO
   SLIDE    3 3
   ENTER


λ:2> x = [True,False]

==================== Proto-BCOs ====================
ProtoBCO x1_r1wJ#0 []:
   GHC.Types.:
     @ GHC.Types.Bool GHC.Types.False (GHC.Types.[] @ GHC.Types.Bool)
   bitmap:  0 []
   PUSH_G   GHC.Types.[]
   PUSH_G   GHC.Types.False
   PACK     : 2
   ENTER

ProtoBCO Ghci2.x#0 []:
   GHC.Types.: @ GHC.Types.Bool GHC.Types.True x1_r1wJ
   bitmap:  0 []
   PUSH_G   x1_r1wJ
   PUSH_G   GHC.Types.True
   PACK     : 2
   ENTER

...

Expected behavior: these two should generate the same byte code, and should be subject to same checks (e.g. for shadowing).

(Example above uses 8.4.4, but this can be reproduced with GHC HEAD too)

Edited by Ömer Sinan Ağacan
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information