Opened 9 years ago

Closed 9 years ago

Last modified 18 months 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: Test Case: read042
Blocked By: Blocking:
Related Tickets: Differential Revisions:

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 9 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to read042

Fixed thank you.

comment:2 Changed 7 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 7 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)

comment:5 Changed 18 months ago by simonpj <simonpj@…>

In 3a87e343e060bec31f42cb4b393ea6b07b25efac/ghc:

Add bang-pattern test

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