Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2490 closed bug (fixed)

GHC allows sections with out parenthesis in tuples

Reported by: JeremyShaw Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: rename/should_fail/T2490
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


GHC gladly accepts:

f x = (head x, ())

but the Haskell 98 Report (section 3.5) seems to indicate that additional parens are required, like this:

f x = ((head x), ())

It's unclear if this is a bug in GHC, an undocumented feature, or valid H98 if you read the report in just the right way.

Hugs and lambdabot don't like it.

More importantly, the trhsx preprocessor used by HSX/HSP does not like it. So, we are wondering if we should extend trhsx to allow it, and if so, what the rules are.

Change History (5)

comment:1 Changed 9 years ago by JeremyShaw

Christian Maeder noted the following:


(+ x, ()) ((), + x) ((), + x, ())

are accepted by GHC

This looks like a bug to me, because

(+, ()) ((), x +)

are rejected.

Sections need to be in parens.

If one allows sections as tuple components, then the latter should may be made legal, too.

comment:2 Changed 9 years ago by JeremyShaw

ack. I didn't notice that the wiki formatting ate my characters on the web page version of this bug.

To summarize, GHC accepts these:

f x = (`head x`, ())
(+ x, ())
((), + x)
((), + x, ())

But not these:

(+, ())
((), x +)

And H98 seems to indicate none of them should be accepted.

comment:3 Changed 9 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed
Test Case: rename/should_fail/T2490

Good point. I've fixed this

Tue Aug 12 09:23:32 BST 2008
  * Fix Trac #2490: sections should be parenthesised

Thanks for a fine report.


comment:4 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.