Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8660 closed bug (invalid)

unexpected parsing error, "in" is treated as reserved word in type class constraints

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


I'm amidst writing a nice ffi binding to BLAS for ghc 7.6 and newer, and I hit an bizarre parser error when i had the follwoing type for a function transpose

transposeMatrix :: (in ~ (Transpose out) , out ~ (Transpose in)  ) => Matrix in elem -> Matrix out elem 
transposeMatrix (RowMajorMatrix x y stride arr)= (ColMajorMatrix x y stride arr)
transposeMatrix (ColMajorMatrix x y stride arr) =(RowMajorMatrix x y stride arr)
    parse error on input ‛in’
Failed, modules loaded: none.

i hit this error in GHC head I built this week AND with ghc 7.6

i'm pretty sure "in" shouldn't be a reserved word in types! If i rename "in" to "inor" the parser error goes away.

if this is valid behavior, it'd be hepful to get a more precise parser error like "encountered reserved word "in", expected a variable"

attaching the full module for your pleasure


Attachments (1)

MatrixTypes.hs (3.4 KB) - added by carter 4 years ago.
matrixtypes file example

Download all attachments as: .zip

Change History (3)

Changed 4 years ago by carter

Attachment: MatrixTypes.hs added

matrixtypes file example

comment:1 Changed 4 years ago by simonpj

Resolution: invalid
Status: newclosed

Well, for better or worse, in is a keyword: see the language definition. Some words like hiding have special significance only in particular places, but in isn't one of them.


comment:2 Changed 4 years ago by carter

agree, I'm moreso suggesting that the error message should be more like

"error, unexpected reserved word "in" at $FILE:LOCATION" rather than "there was a syntax error here".

Note: See TracTickets for help on using tickets.