Opened 18 months ago

Closed 18 months ago

Last modified 18 months 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 Revisions:

Description

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)
src/Numerical/OpenBLAS/MatrixTypes.hs:83:21:
    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

thanks!

Attachments (1)

MatrixTypes.hs (3.4 KB) - added by carter 18 months ago.
matrixtypes file example

Download all attachments as: .zip

Change History (3)

Changed 18 months ago by carter

matrixtypes file example

comment:1 Changed 18 months ago by simonpj

  • Resolution set to invalid
  • Status changed from new to closed

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.

Simon

comment:2 Changed 18 months 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.