Skip to content

internal error with rebindable if-then-else

Defining ifThenElse in a module with RebindableSyntax enabled and using if-then-else in the same module leads to an internal ghc error.

ifThenElse.hs:

{-# LANGUAGE RebindableSyntax #-}

module IfThenElse (ifThenElse) where

import Prelude (Bool(..))

ifThenElse True t f = t
ifThenElse False t f = f

foo = if True then () else ()

Error message:

# ghc IfThenElse.hs
[1 of 1] Compiling IfThenElse       ( IfThenElse.hs, IfThenElse.o )

IfThenElse.hs:10:7:
    GHC internal error: `ifThenElse' is not in scope during type checking, but it passed the renamer
    tcg_type_env of environment: []
    tcl_env of environment: []
    In the expression: if True then () else ()
    In an equation for `foo': foo = if True then () else ()

Importing ifThenElse from another module (even with RebindableSyntax enabled) will make the error go away.

Trac metadata
Trac field Value
Version 7.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC p.balzarek@googlemail.com
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information