Skip to content

-fdefer-typed-holes causes panic on unbound variable

module Main where

main = do
    print v
    return ()

Compile it without -fdefer-typed-holes and it fails as expected:

➜  hole_bug ghc --make Main.hs -fforce-recomp 
[1 of 1] Compiling Main             ( Main.hs, Main.o )

Main.hs:4:11: error: Variable not in scope: v

Adding -fdefer-typed-holes is causing a panic instead of runtime error:

➜  hole_bug ghc --make Main.hs -fforce-recomp -fdefer-typed-holes
[1 of 1] Compiling Main             ( Main.hs, Main.o )

Main.hs:4:11: warning: [-Wtyped-holes] Variable not in scope: v
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
        StgCmmEnv: variable not found
  $dShow_aKo
  local binds for:
  $trModule
  $trModule1_r16k
  $trModule2_r16s
  sat_s16x
  sat_s16z

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Tried with: 8.0.1, HEAD as of today.

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information