Opened 12 years ago

Closed 12 years ago

#2111 closed merge (fixed)

Incorrect arrow rec {} notation crashes in ghci

Reported by: luqui Owned by: igloo
Priority: normal Milestone:
Component: Compiler Version: 6.8.1
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Test Case: T2111
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

[ ~ ]% ghci -fglasgow-exts -farrows                                                                         
GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> do { rec { x <- undefined -< x }; undefined -< x }
ghc-6.8.1: panic! (the 'impossible' happened)
  (GHC version 6.8.1 for i386-unknown-linux):
        tcDoStmt: unexpected Stmt
    rec {(x{v anj}) <- base:GHC.Err.undefined{v rle} -< x{v anj}}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Prelude> Leaving GHCi.
[ ~ ]% ghc --version                                                                                         
The Glorious Glasgow Haskell Compilation System, version 6.8.1
[ ~ ]% uname -a                                                                                             
Linux madhatter 2.6.22-gentoo-r8 #6 PREEMPT Sat Oct 20 04:19:22 GMT 2007 i686 AMD Turion(tm) 64 Mobile Technology ML-40 AuthenticAMD GNU/Linux

Change History (4)

comment:1 Changed 12 years ago by ross

The -farrows option turns on the rec keyword, but then you get this even without using arrow notation:

Prelude> do { rec { x <- return ('a':x); }; putStrLn (take 20 x) }
ghc-6.8.2: panic! (the 'impossible' happened)
  (GHC version 6.8.2 for i386-unknown-linux):
        tcDoStmt: unexpected Stmt
    rec {(x{v aon}) <- base:GHC.Base.return{v 01T}
                         ('a' base:GHC.Base.:{(w) d 64} x{v aon})}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

but if do is replaced with mdo, it works:

Prelude> mdo { rec { x <- return ('a':x); }; putStrLn (take 20 x) }
aaaaaaaaaaaaaaaaaaaa

This is because tcDoStmt does not handle RecStmt. In the original example, the correct behaviour would be to object to the use of arrow application in an expression, as it does with mdo:

Prelude> mdo { rec { x <- undefined -< x }; undefined -< x }

<interactive>:1:17:
    The arrow command
      undefined -< x
    was found where an expression was expected
    In an 'mdo' expression: x <- undefined -< x
    In an 'mdo' expression: rec {x <- undefined -< x}
    In the expression:
        mdo rec {x <- undefined -< x}
            undefined -< x

comment:2 Changed 12 years ago by simonpj

difficulty: Unknown
Owner: set to simonpj

I'll fix

comment:3 Changed 12 years ago by simonpj

Owner: changed from simonpj to igloo
Test Case: T2111
Type: bugmerge

Fixed by

Tue Feb 26 17:56:35 GMT 2008  simonpj@microsoft.com
  * Fix Trac #2111: improve error handling for 'rec' in do-notation

Simon

comment:4 Changed 12 years ago by igloo

Resolution: fixed
Status: newclosed

Merged

Note: See TracTickets for help on using tickets.