Opened 9 years ago

Closed 9 years ago

#5038 closed bug (fixed)

internal error with rebindable if-then-else

Reported by: Philonous Owned by: simonpj
Priority: high Milestone: 7.2.1
Component: Compiler Version: 7.0.2
Keywords: Cc: p.balzarek@…
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case: rebindable/T5038
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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


{-# 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 )

    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.

Change History (3)

comment:1 Changed 9 years ago by simonpj

Ahem. Yes. Patch coming. Thanks.

comment:2 Changed 9 years ago by igloo

Milestone: 7.2.1
Owner: set to simonpj
Priority: normalhigh

comment:3 Changed 9 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: rebindable/T5038

Fixed by:

commit 3f9d24d5188214f769552ad96876346d35366761
Author: simonpj <>
Date:   Tue Apr 19 13:36:11 2011 +0100

    Fix Trac #5038 (missing free variable in ifThenElse rebindable syntax)

 compiler/rename/RnEnv.lhs  |   13 ++++++++++++-
 compiler/rename/RnExpr.lhs |   11 ++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)


Note: See TracTickets for help on using tickets.