error-messages icon indicating copy to clipboard operation
error-messages copied to clipboard

Helpful "not in scope before the splice" went missing in 9.0

Open tomjaguarpaw opened this issue 2 years ago • 6 comments

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

tomjaguarpaw avatar Sep 10 '23 08:09 tomjaguarpaw

This has caused confusion in real life: https://discourse.haskell.org/t/does-template-haskell-move-things-out-of-the-scope/7549/15

tomjaguarpaw avatar Sep 10 '23 09:09 tomjaguarpaw

Earlier discussion: https://gitlab.haskell.org/ghc/ghc/-/issues/17816#note_256167

monoidal avatar Sep 11 '23 14:09 monoidal

Thanks @monoidal!

(I realised I've posted this on the wrong issue tracker. I'll try to find the correct one...)

tomjaguarpaw avatar Sep 11 '23 14:09 tomjaguarpaw

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.

tomjaguarpaw avatar Sep 11 '23 14:09 tomjaguarpaw

Yes - error-message-index is used to describe existing errors, while this one is for improving them.

monoidal avatar Sep 11 '23 14:09 monoidal

Apparently it took "hundreds of lines of code" to support this error message!

https://gitlab.haskell.org/ghc/ghc/-/issues/17816#note_256193

tomjaguarpaw avatar Sep 11 '23 14:09 tomjaguarpaw