Skip to content

Improve error message about closed variables

After allowing local bindings in static definitions the following program

{-# LANGUAGE StaticPointers #-}
module M where

f x = static g
  where
    g = h
    h = x

yields the error

../tmp/M.hs:4:7: error:
    • ‘g’ is used in a static form but it is not closed.
    • In the expression: static g
      In an equation for ‘f’:
          f x
            = static g
            where
                g = h
                h = x

where it would be more helpful to get a message like

../tmp/M.hs:4:7: error:
    • ‘g’ is used in a static form but it is not closed because it
      uses ‘h’ which uses ‘x’ which is not let-bound.
    • In the expression: static g
      In an equation for ‘f’:
          f x
            = static g
            where
                g = h
                h = x
Edited by Facundo Domínguez
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information