error-messages
error-messages copied to clipboard
Helpful "not in scope before the splice" went missing in 9.0
In the program below, c is not in scope where a is defined because of the intervening TH splice. The error message in 8.10 was helpful
test18.hs:6:5: error:
• Variable not in scope: c :: Int
• ‘c’ (line 11) is not in scope before the splice on line 8
In 9.0 the error message became unhelpful
test18.hs:6:5: error: Variable not in scope: c :: Int
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.Syntax
a :: Int
a = c
$(pure [])
c :: Int
c = 0
This has caused confusion in real life: https://discourse.haskell.org/t/does-template-haskell-move-things-out-of-the-scope/7549/15
Earlier discussion: https://gitlab.haskell.org/ghc/ghc/-/issues/17816#note_256167
Thanks @monoidal!
(I realised I've posted this on the wrong issue tracker. I'll try to find the correct one...)
Actually perhaps it is the correct one, per https://github.com/haskell/error-messages#the-haskell-message-index. I got confused between this one and https://github.com/haskellfoundation/error-message-index, but I think this is the correct one for general issues around error messages.
Yes - error-message-index is used to describe existing errors, while this one is for improving them.
Apparently it took "hundreds of lines of code" to support this error message!
https://gitlab.haskell.org/ghc/ghc/-/issues/17816#note_256193