Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • 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,826
    • Issues 4,826
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 441
    • Merge requests 441
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16183

Closed
Open
Created Jan 14, 2019 by Ryan Scott@RyanGlScottMaintainer

GHC HEAD regression: -ddump-splices incorrectly parenthesizes HsKindSig applications

When you compile this file with GHC 8.6.3 and HEAD:

{-# LANGUAGE KindSignatures #-}                                                                    
{-# LANGUAGE TemplateHaskell #-}                                                                   
{-# OPTIONS_GHC -ddump-splices #-}                                                                 
module Bug where                                                                                   
                                                                                                   
import Data.Kind                                                                                   
                                                                                                   
type F = $([t| (Maybe :: Type -> Type) Int |])

You get two different results:

$ /opt/ghc/8.6.3/bin/ghc -fforce-recomp Bug.hs                                                    
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )                                              
Bug.hs:8:12-45: Splicing type                                                                      
    [t| (Maybe :: Type -> Type) Int |]                                                             
  ======>                                                                                          
    (Maybe :: Type -> Type) Int                                                                    
                                                              
$ ~/Software/ghc4/inplace/bin/ghc-stage2 -fforce-recomp Bug.hs                                     
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )                                              
Bug.hs:8:12-45: Splicing type
    [t| (Maybe :: Type -> Type) Int |]
  ======>
    Maybe :: Type -> Type Int

Notice how in the GHC HEAD output, GHC forgets to put parentheses around Maybe :: Type -> Type, leading to the utterly nonsensical type Maybe :: Type -> Type Int.

The commit that introduced this regression is bace26aadaafa4064e78f9ed088c1e2217221acc.

Edited Mar 10, 2019 by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking