Opened 6 years ago

Closed 6 years ago

Last modified 6 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: Difficulty: Unknown
Test Case: rename/should_fail/T2490 Blocked By:
Blocking: Related Tickets:

Description

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 6 years ago by JeremyShaw

Christian Maeder noted the following:

Also

(+ 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 6 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 6 years ago by simonpj

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to rename/should_fail/T2490

Good point. I've fixed this

Tue Aug 12 09:23:32 BST 2008  simonpj@microsoft.com
  * Fix Trac #2490: sections should be parenthesised

Thanks for a fine report.

Simon

comment:4 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:5 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.