Skip to content

GHC suggests an out of scope variable in a parallel list comprehension

Summary

When you use a variable from one branch of a parallel list comprehension in another branch, ghc will correctly report it as an out of scope variable but suggest it as an alternative.

Steps to reproduce

ghci> :set -XParallelListComp
ghci> [ (a, b) | a <- [0 ..] | b <- "abcd", even a ]

<interactive>:5:44: error:
    • Variable not in scope: a
    • Perhaps you meant ‘a’ (line 5)

Expected behavior

It should not suggest the variable that is out of scope.

Environment

  • GHC version used: 9.2.5, but also seen in 9.4.4 and 8.10.7

Optional:

  • Operating System: Ubuntu 20.04.1
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information