Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,830
    • Issues 4,830
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 447
    • Merge requests 447
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18950

Closed
Open
Created Nov 14, 2020 by JustMoi@JustMoi

ghc: panic! (the 'impossible' happened) - GHC.StgToCmm.Env: variable not found - Arrows GADTs ExistentialQuantification

Summary

Compiling Example.hs causes ghc to panic.

Example.hs

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
  • 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 and proc
  • 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
  • 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 of step is Arrow a => a Obj Obj; but, if it were Arrow 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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking