Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,930
    • Issues 4,930
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16133
Closed
Open
Created Jan 05, 2019 by Ryan Scott@RyanGlScottMaintainer

TH can sneak in TypeApplications without enabling the extension

This program compiles:

{-# LANGUAGE TemplateHaskell #-}
module Bug1 where

import Language.Haskell.TH

$([d| f :: Int
      f = $(varE 'id `appTypeE` conT ''Int `appE` litE (integerL 42)) |])

But it shouldn't: this splices in code that uses TypeApplications, but the language extension isn't enabled! What's worse, this is inconsistent with visible kind applications, since the following code //is// rejected:

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
module Bug2 where

import Data.Kind
import Language.Haskell.TH hiding (Type)

data P (a :: k) = MkP

$([d| type P' = $(conT ''P `appKindT` conT ''Type) |])
$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug2.hs
[1 of 1] Compiling Bug2             ( Bug2.hs, Bug2.o )

Bug2.hs:10:3: error:
    Illegal visible kind application ‘Type’
      Perhaps you intended to use TypeApplications
   |
10 | $([d| type P' = $(conT ''P `appKindT` conT ''Type) |])
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Let's bring the two into harmony. Patch incoming.

Trac metadata
Trac field Value
Version 8.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking