Ticket #1814 (closed merge: fixed)

Opened 7 months ago

Last modified 6 months ago

Lightweight quoting Stage error in interactive mode

Reported by: guest Assigned to: igloo
Priority: normal Milestone: 6.10 branch
Component: Template Haskell Version: 6.9
Severity: normal Keywords:
Cc: alfonso.acosta@gmail.com Difficulty: Unknown
Test Case: TH_ghci1 Architecture: Unknown
Operating System: Unknown

Description

ghc/compiler/stage2$ ./ghc-inplace --interactive -fth
GHCi, version 6.9.20071025: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> :m +Language.Haskell.TH
Prelude Language.Haskell.TH> let f = 1
Prelude Language.Haskell.TH> :m +Language.Haskell.TH
Prelude Language.Haskell.TH> $(do {i <- reify 'f; runIO $ putStrLn (pprint i); [| 1 |]})

<interactive>:1:17:
    Stage error: the non-top-level quoted name 'f
    must be used at the same stage at which is is bound
    In the first argument of `reify', namely 'f
    In a 'do' expression: i <- reify 'f
    In the expression:
        $(do i <- reify 'f
               runIO $ putStrLn (pprint i)
             [| 1 |])

This error didn't show with version 6.6

$ ghci -fth
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> let f = 1
Prelude> :m +Language.Haskell.TH
Prelude Language.Haskell.TH> $(do {i <- reify 'f; runIO $ putStrLn (pprint i); [| 1 |]})
Loading package template-haskell ... linking ... done.
f_0 :: GHC.Num.Integer
f_0 :: GHC.Num.Integer
f_0 :: GHC.Num.Integer
f_0 :: GHC.Num.Integer
1
Prelude Language.Haskell.TH> 

Change History

11/05/07 14:29:22 changed by igloo

  • milestone set to 6.10 branch.

Thanks for the report. It seems reasonable to me that this should work (and it doesn't in 6.8.1). However, we can't fix it until 6.10 now, sorry.

11/06/07 07:15:33 changed by simonpj

  • testcase set to TH_ghci1.
  • owner set to igloo.
  • type changed from bug to merge.

Excellent point. I've fixed it and added comments explaining why it wasn't right the first time.

The HEAD patch (which should merge onto the 6.8 branch is

Tue Nov  6 13:55:48 GMT 2007  simonpj@microsoft.com
  * Fix Trac #1814 (staging interaction in Template Haskell and GHCi), and add comments

11/10/07 05:49:30 changed by igloo

  • status changed from new to closed.
  • resolution set to fixed.

Merged (and I have no idea why I thought it would have to wait until 6.10)