ghc: panic! (the 'impossible' happened) - GHC.StgToCmm.Env: variable not found - Arrows GADTs ExistentialQuantification
Summary
Compiling Example.hs
causes ghc to panic.
The provided Example.hs
source file contains a full set of notes regarding which changes reveal (or hide) the panic.
- The function
step
must be exported- -- NOTE: no error if
step
not exported
- -- NOTE: no error if
- Definition of datatype Point must have a context
- -- NOTE: no error without 'RealFloat a` context; both examples fail
- Example fails when using either of the GADT or ExistentialQuanitification extensions
- ExistentialQuantification version is commented out
-
step
function where error occurs uses Arrow extensions andproc
- The error is depends on how the value is deconstructed
- -- NOTE: no error without this arrow line; no error if not deconstructed.
(Point _) <- ptrPos -< gi
- -- NOTE: this two-line code does work (in place of
(Point _) <- ptrPos -< gi
above)pt <- ptrPos -< gi; let (Point _) = pt
- -- NOTE: no error without this arrow line; no error if not deconstructed.
- The returned object record must have a
Point
field- -- NOTE: no error without this 'pos' field
- In the simplified
Example.hs
provided, this isn't as relevant because the signature ofstep
isArrow a => a Obj Obj
; but, if it wereArrow a => a ObjA ObjB
(similar to original version), I recall that if ObjB didn't have an existentially qualified field, the panic didn't occur.
Steps to reproduce
nix-shell -I nixpkgs=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz -p haskell.compiler.ghc901
ghc Example.hs
Result:
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.0.20200925:
GHC.StgToCmm.Env: variable not found
$dRealFloat_a1tn
local binds for:
pos
Point
Obj
$dArrow_s1xr
ds_s1xs
ds1_s1xt
ds2_s1ya
ds3_s1yb
ds4_s1yc
ds6_s1ye
sat_s1yf
sat_s1yg
sat_s1yh
sat_s1yi
sat_s1yj
sat_s1yk
sat_s1yl
sat_s1ym
sat_s1yn
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/StgToCmm/Env.hs:152:9 in ghc:GHC.StgToCmm.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Expected behavior
Compile without error.
Environment
- GHC version used: 8.8.x, 8.10.x, and 9.0.x
Optional:
- Operating System: Ubuntu + Nix (Nixpkgs for GHC)
- System Architecture: x86_64
- Example.hs (duplicate): Example.hs