UU-ComputerScience / uhc

136 stars 21 forks source link

Definition of infix function x ! y is misparsed as bang pattern #70

Closed nick8325 closed 8 years ago

nick8325 commented 8 years ago

Hi,

The following code should define a binary function (!) and then use it to define a value x:

(!) :: a -> b -> c
x ! y = undefined
x = 0 ! 0

Unfortunately, I get an error that x is defined twice:

Name(s) for value(s) introduced more than once:
    Test.x: Test.hs:4:1 (function)
            Test.hs:5:1 (value)

The reason is that in the definition x ! y = undefined, the ! is parsed as a bang pattern so it becomes x (!y) = undefined. This causes the containers package to fail to compile on UHC.

I worked around this by defining (!) prefix but thought I should report it anyway.

atzedijkstra commented 8 years ago

This could have been fixed by using NoBangPatterns language pragma were it not for the fact that the propagation to the parser was broken (fixed now). Also the default now is NoBangPatterns, to be turned on explicitly with BangPatterns.