Opened 10 years ago

Closed 10 years ago

Last modified 3 years ago

#1041 closed bug (fixed)

Bang patterns in do notation and lambdas

Reported by: dons Owned by:
Priority: normal Milestone:
Component: Compiler (Parser) Version: 6.6
Keywords: bang patterns Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: read042
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Bang patterns in do-notation and lambdas need parentheses around them to parse. This isn't the case for ~ patterns, or bang patterns in let bindings. Seems like a wibble.

{-# OPTIONS -fbang-patterns #-}

-- doesn't work:        A.hs:5:8: Empty 'do' construct
main1 = do
    !c <- return ()
    return ()

-- doesn't work:        A.hs:12:24: parse error on input `!'
main2 = return () >>= \ !c -> return ()



-- does
main3 = do
    (!c) <- return ()
    return ()

-- does
main4 = return () >>= \ (!c) -> return ()


-- does
main5 = let !x = 1 in return ()


-- does
main6 = do
    ~c <- return ()
    return ()

-- does
main7 = return () >>= \ ~c -> return ()

-- dons

Change History (5)

comment:1 Changed 10 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: read042

Fixed thank you.

comment:2 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:3 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:4 Changed 8 years ago by simonmar

difficulty: Easy (1 hr)Easy (less than 1 hour)

comment:5 Changed 3 years ago by simonpj <simonpj@…>

In 3a87e343e060bec31f42cb4b393ea6b07b25efac/ghc:

Add bang-pattern test

Fixes Trac #1041
Note: See TracTickets for help on using tickets.