Fsharp: Parse error on generic abstract member definition

Created on 29 Apr 2019  路  4Comments  路  Source: dotnet/fsharp

Removing the space before the colon in the following code results in a parse error with no error recovery.

[<AbstractClass>]
type T() =
    abstract Foo<'T> : 'T -> int

abstractGenericMethodSpace

Area-Compiler Feature Improvement error recovery

Most helpful comment

Ugh, of course it's not just the SRTP issue here too :(

I updated the design: https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1083-srtp-type-no-whitespace.md

Tiny update. I didn't rename the file since that would break links though. We'll keep this issue up though.

All 4 comments

The same happens for bindings in signature files:

val c<'T> : int
val c<'T>: int

Screenshot 2020-08-12 at 19 14 14

As the message suggests, it's considered an operator. The parser could do some look ahead to permit this kind of construct. I believe there's an RFC for a similar issue with <^t>, which also fails.

I think it would be good to add this to the rfc here, though it's not exactly the same, it falls in the same area of look ahead for operators: https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1083-srtp-type-no-whitespace.md.

Original suggestion: https://github.com/fsharp/fslang-suggestions/issues/668

Ugh, of course it's not just the SRTP issue here too :(

I updated the design: https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1083-srtp-type-no-whitespace.md

Tiny update. I didn't rename the file since that would break links though. We'll keep this issue up though.

Was this page helpful?
0 / 5 - 0 ratings