Skip to content

STG scope error

StgRhsClosure can contain duplicated names in its free variable and argument list.

Example bug: libraries/integer-gmp/src/GHC/Integer/Type.hs

GHC HEAD and 8.2.2 has this issue.

I have not checked with other versions.

I've extended the STG linter to do scope checking. See the patch attached.

To reproduce:

  • patch GHC head: git apply StgScopeCheck.patch
  • make sure every compiled stg is linted: add the following to mk/build.mk\\
GhcStage2HcOpts += -dstg-lint
GhcLibHcOpts += -dstg-lint
GhcRtsHcOpts += -dstg-lint
  • compile GHC HEAD

Background info: I've found this issue because I'm using GHC as a Haskell fronted for my whole program compiler project. I work on The GRIN Compiler (https://github.com/grin-tech) where GHC/GRIN compiles STG to GRIN.

Edited by Csaba Hruska
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information