fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Unexpected keyword error when there's no keyword

Open abelbraaksma opened this issue 5 years ago • 0 comments

Basically just:

> let i:float`1 = 3.0;;
  let i:float`1 = 3.0;;
  -----------^
stdin(4,12): error FS0010: Unexpected reserved keyword in binding. Expected '=' or other token.

The backtick ` maybe reserved, but certainly isn't a keyword, right?

Same is true for the operator ~ (which normally serves as a prefix for other operators):

> let i:float~1 = 3.0;;
  let i:float~1 = 3.0;;
  -----------^
stdin(7,12): error FS0010: Unexpected reserved keyword in binding. Expected '=' or other token.

And this one is certainly surprising (! is an actual overridable operator), any future use in the plans? :)

> let i:float!1 = 3.0;;
  let i:float!1 = 3.0;;
  ------^^^^^^
stdin(8,7): error FS1141: Identifiers followed by '!' are reserved for future use

Note that if you use something more operator-like, you get a more useful message, which I think should be the message for the above ones as well, or just use wording like "reserved operator":

> let i:float@1 = 3.0;;
  let i:float@1 = 3.0;;
  -----------^
stdin(6,12): error FS0615: Unexpected infix operator in type expression

abelbraaksma avatar Aug 31 '20 14:08 abelbraaksma