Skip to content

Wrong confusing warning FS1189 when using SRTP with active patterns #7797

Open
@abelbraaksma

Description

@abelbraaksma

This is fine:

let inline IsEqual< ^t  when ^t: equality> (x: ^t)  = 
    x = x

But this is not:

let inline (|IsEqual|IsNonEqual|)< ^t  when ^t : equality> (x: ^t)  = 
    if x = x then -> IsEqual
    else IsNonEqual

image

Note: the code above does not require an explicit SRTP, but I just wanted to keep it simple. The actual example came from my comment here: fsharp/fslang-suggestions#661 (comment)

It can be seen with any SRTP type constraint, the full warning being:

warning FS1189: Remove spaces between the type name and type parameter, e.g. "type C<'T>", not type "C <'T>". Type parameters must be placed directly adjacent to the type name.

Known workarounds

Ignore the warning (but that will ignore it for the whole file).

Other info

It has been reported before, but writing <^t instead of < ^t will yield a syntax error. Though I doubt that is the space the compiler complains about.

Also: the actual warning doesn't seem tailored for SRTP, it shows examples for normal type constraints, which can be confusing.

Metadata

Metadata

Assignees

Labels

Area-Compiler-Syntaxlexfilter, indentation and parsingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

Projects

Status

New

Relationships

None yet

Development

No branches or pull requests

Issue actions