Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abelbraaksma opened this issue Oct 31, 2019 · 0 comments
Open
Labels
Area-Compiler-Syntax lexfilter, indentation and parsing Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Oct 31, 2019

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.

@abelbraaksma abelbraaksma changed the title Wrong confusing warning when using SRTP with active patterns Wrong confusing warning FS1189 when using SRTP with active patterns Oct 31, 2019
@cartermp cartermp added Area-Compiler Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. labels Jun 20, 2020
@cartermp cartermp added this to the Backlog milestone Jun 20, 2020
@dsyme dsyme added Area-Compiler-PatternMatching pattern compilation, active patterns, performance, codegen and removed Area-Compiler labels Mar 31, 2022
@dsyme dsyme added Area-Compiler-Syntax lexfilter, indentation and parsing and removed Area-Compiler-PatternMatching pattern compilation, active patterns, performance, codegen labels Apr 20, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Syntax lexfilter, indentation and parsing Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Status: New
Development

No branches or pull requests

3 participants