Opened 3 years ago

Closed 3 years ago

#12459 closed bug (fixed)

UnboxedTuple makes overloaded labels fail to parse

Reported by: Iceland_jack Owned by: adamgundry
Priority: normal Milestone: 8.2.1
Component: Compiler (Parser) Version: 8.0.1
Keywords: orf Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Documentation bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3144
Wiki Page:


This works (removing spaces)

-- user = ( #login := "themoritz", #id := 3522732 )

user :: User
user = (#login := "themoritz", #id := 3522732)

but it doesn't when UnboxedTuples are enabled:

-- tWKw.hs:63:46: error: parse error on input ‘)’
user = (#login := "themoritz", #id := 3522732)

Attachments (1)

Change History (11)

comment:1 Changed 3 years ago by Iceland_jack

This forces users to add a space in the rare case of mixing UnboxedTuples and overloaded labels.

main = do
  print $ #url mentioned
  print $ #login ( #user mentioned )
  print $ ( #id . #user ) mentioned
Last edited 3 years ago by Iceland_jack (previous) (diff)

comment:2 Changed 3 years ago by bgamari

Cc: adamgundry added

Hmm, is this an interaction that you anticipated, Adam?

comment:3 Changed 3 years ago by rwbarton

We should probably just say this is working as intended: (# is a single token under UnboxedTuples.

comment:4 Changed 3 years ago by Iceland_jack

I bumped into this because I have UnboxedTuples enabled in my .ghci but in a future where OverloadedLabels are ubiquitous a user cannot use unboxed tuples without modifying every parenthesised label in the module first: potentially resulting in large diffs, potentially going against the style of the project (or style guide).

Not a huge concern but definitely raises an eyebrow

This could of course be ameliorated by local language pragmas ;) think about it (local Strict, RebindableSyntax)

comment:5 Changed 3 years ago by adamgundry

No, I hadn't considered the interaction with unboxed tuple syntax. It is a bit awkward, but the lexical syntax is sufficiently crowded that I doubt we will be able to do better, and we already have similar annoyances involving .hsc files. I suppose we could add a sentence to the manual pointing out the conflict and encouraging a style in which overloaded labels are preceded by a space (even when in parentheses).

comment:6 Changed 3 years ago by simonpj

Yes -- a note in the manual would be hugely helpful. Might you send a patch? Thanks!

comment:7 Changed 3 years ago by adamgundry

Milestone: 8.2.1
Owner: set to adamgundry

comment:8 Changed 3 years ago by jberryman

Does this have much to do with overloaded labels? As rwbarton points out, it seems any occurence of "(#" has issues:

ubuntu@ip-172-31-8-51:~/work/ghc-my$ ghci
GHCi, version 8.1.20160920:  :? for help
Prelude> :set -XUnboxedTuples
Prelude> let (#) = (+)

<interactive>:2:7: error: parse error on input ‘)’

comment:9 Changed 3 years ago by adamgundry

Differential Rev(s): Phab:D3144
Status: newpatch
Type of failure: GHC rejects valid programDocumentation bug

I've included a comment in my documentation updates for the recent changes to overloaded labels. The unboxed tuples docs already mention that (# is a single lexeme.

comment:10 Changed 3 years ago by bgamari

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.