-fobject-code in ghci breaks top-level declarations
Summary
Top-level declarations work without -fobject-code in ghci but silently break with it.
Steps to reproduce
In ghci:
Prelude> x :: Int; x = 1
Prelude> x
1
Prelude> :set -fobject-code
Prelude> y :: Int; y = 1
Prelude> y
<interactive>:5:1: error: Variable not in scope: y
Expected behavior
I would expect that y would be in scope. Or at least, that the documentation for -fobject-code would mention this and that the error message would be more helpful. Even discovering that -fobject-code is the culprit wasn't easy.
Environment
- GHC version used: I've tried several going from 7.8.3 to 9.0.1