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,842
    • Issues 4,842
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • 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
  • #14875

Closed
Open
Created Mar 02, 2018 by Ryan Scott@RyanGlScottMaintainer

-ddump-splices pretty-printing oddities with case statements

The latest installment in "Ryan finds minor bugs in -ddump-splices". Take this program:

{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where

$([d| f :: Bool -> Bool
      f x = case x of
              (True :: Bool) -> True
              (False :: Bool) -> False

      g :: Bool -> Bool
      g x = (case x of
               True -> True
               False -> False) :: Bool
    |])

Compiling this gives:

$ /opt/ghc/8.2.2/bin/ghci Bug.hs
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Bug.hs:(6,3)-(15,6): Splicing declarations
    [d| f_a1sB :: Bool -> Bool
        f_a1sB x_a1sD
          = case x_a1sD of
              (True :: Bool) -> True
              (False :: Bool) -> False
        g_a1sC :: Bool -> Bool
        g_a1sC x_a1sE
          = (case x_a1sE of
               True -> True
               False -> False) ::
              Bool |]
  ======>
    f_a49Z :: Bool -> Bool
    f_a49Z x_a4a0
      = case x_a4a0 of
          True :: Bool -> True
          False :: Bool -> False
    g_a49Y :: Bool -> Bool
    g_a49Y x_a4a1
      = case x_a4a1 of
          True -> True
          False -> False ::
          Bool

Neither the -ddump-splices output for f nor g parse are legal Haskell:

  • In f, GHC fails to parenthesize the pattern signatures True :: Bool and False :: Bool.
  • In g, GHC fails to parenthesize the case expression which has an explicit Bool signature.
Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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