Ticket #5752 (closed bug: duplicate)

Opened 17 months ago

Last modified 14 months ago

<<loop>> when using variables in TH splice

Reported by: srl Owned by:
Priority: normal Milestone: 7.6.1
Component: Template Haskell Version: 7.0.3
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When compiling the attached (which uses a variable 'x' in a TH splice in a data decl), the following error is given:

[1 of 1] Compiling Main ( b.hs, b.o )

b.hs:11:80:ghc: panic! (the 'impossible' happened)

(GHC version 7.0.3 for x86_64-unknown-linux):

<<loop>>

Attachments

b.hs Download (207 bytes) - added by srl 17 months ago.
Code that triggers <loop> in ghc.

Change History

Changed 17 months ago by srl

  • attachment b.hs Download added

Code that triggers <loop> in ghc.

Changed 17 months ago by igloo

  • difficulty set to Unknown
  • milestone set to 7.6.1

Thanks for the report.

The code is:

{-# LANGUAGE TemplateHaskell #-}

module Main where

import Language.Haskell.TH

main = undefined

x = 3

data A = A $( return . (\ts -> foldl AppT (TupleT (length ts)) ts) . replicate x =<< [t| Double |] )

HEAD and 7.4 give:

q.hs:12:80:
    GHC internal error: `x' is not in scope during type checking, but it passed the renamer
    tcl_env of environment: [(rfT, AThing *), (rfU, ANothing)]
    In the first argument of `replicate', namely `x'
    In the second argument of `(.)', namely `replicate x'
    In the second argument of `(.)', namely
      `(\ ts -> foldl AppT (TupleT (length ts)) ts) . replicate x'

It looks to me like the code is wrong, but we should get a proper error that x can't be used in a splice in the module that defines it.

Changed 14 months ago by simonpj

  • status changed from new to closed
  • resolution set to duplicate

Right. This is a dup of #5795 (which is simpler).

Note: See TracTickets for help on using tickets.