Ticket #1041 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

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: Difficulty: Easy (less than 1 hour)
Test Case: read042 Blocked By:
Blocking: Related Tickets:

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

Changed 6 years ago by simonpj

  • status changed from new to closed
  • testcase set to read042
  • resolution set to fixed

Fixed thank you.

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.