[GHC] #12091: 'Variable not in scope" when using GHCi with `-fobject-code`

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: Type: bug | Status: new Priority: high | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #7253 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Since b98ff3ccb14e36145404f075349c8689762a2913 was landed (#7253), you don't need `let` to define stuff in GHCi: {{{ $ ghci Prelude> x = 3 Prelude> x 3 }}} But when using `-fobject-code`, this results in an error: {{{ $ ghci -fobject-code Prelude> x = 3 Prelude> x <interactive>:2:1: error: Variable not in scope: x }}} Very strange. CC @roshats, who implemented this feature, but the bug is probably in some part of the code he didn't touch. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: Type: bug | Status: new Priority: high | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7253 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): I know the problem but I don't know how to fix it. `let x = ...` is compiled as a statement, `x = ...` is compiled as a declaration. Desugarer dumps unused declarations if the target is not `HscInterpreted` or `HscNothing` (see `DynFlags.targetRetainsAllBindings`), but nothing like that is done for statements. Since `-fobject-code` sets target something other than `HscInterpreted` and `HscNothing`, `x` gets dumped. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: Type: bug | Status: new Priority: high | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7253 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): This is related with @roshats's patch as that's where we choose to compile `x = ...` as a statement instead of declaration (by "desugaring" it into `let x = ...`). Maybe we can do that now, unless someone has a better idea. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code`
-------------------------------------+-------------------------------------
Reporter: thomie | Owner:
Type: bug | Status: new
Priority: high | Milestone:
Component: GHCi | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #7253 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7253, #14108 | Differential Rev(s): Phab:D3849 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3849 * related: #7253 => #7253, #14108 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code`
-------------------------------------+-------------------------------------
Reporter: thomie | Owner: (none)
Type: bug | Status: patch
Priority: high | Milestone:
Component: GHCi | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #7253, #14108 | Differential Rev(s): Phab:D3849
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7253, #14108 | Differential Rev(s): Phab:D3849 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7253, #14108 | Differential Rev(s): Phab:D3849 Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): I reverted ddb870bf7055ccc8ff8b86c161f31aad81d01add in https://gitlab.haskell.org/ghc/ghc/merge_requests/97, which fixes the difference between `x = ...` and `let x = ...` in GHCi. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code` -------------------------------------+------------------------------------- Reporter: thomie | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7253, #14108 | Differential Rev(s): Phab:D3849 Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): The MR in comment:7 is merged as a34ee6154. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12091#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12091: 'Variable not in scope" when using GHCi with `-fobject-code`
-------------------------------------+-------------------------------------
Reporter: thomie | Owner: (none)
Type: bug | Status: closed
Priority: high | Milestone: 8.4.1
Component: GHCi | Version: 8.0.1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #7253, #14108 | Differential Rev(s): Phab:D3849
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ömer Sinan Ağacan
participants (1)
-
GHC