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

Separator between member and type annotation interpreted as operator #4607

Closed
cartermp opened this issue Mar 22, 2018 · 4 comments · Fixed by #15923
Closed

Separator between member and type annotation interpreted as operator #4607

cartermp opened this issue Mar 22, 2018 · 4 comments · Fixed by #15923
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

@cartermp
Copy link
Contributor

cartermp commented Mar 22, 2018

Given the following:

type IFoo<'T> =
    abstract member Bar<'T>: name: string -> unit

Expected:

Compiles.

Actual:

Compiler error.

This construct is deprecated: ':' is not permitted as a character in operator names and is reserved for future use

Workaround:

Put a space after the >:

type IFoo<'T> =
    abstract member Bar<'T> : name: string -> unit

Thanks to @jaredpar for pointing this out

Info

Latest F# compiler in VS Preview

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Mar 23, 2018

I think in a way this is similar to static member constraints, similar because I think the compiler misinterprets >: as an operator, just as here:

let inline internal getValue<^a when ^a : (member Value : string option)> value =
    ( ^a : (member Value : string option)(value))

This raises "Unexpected infix operator in pattern". Or simpler, same error:

let inline internal getValue<^a>(value: ^a) = value

I was quite sure I reported that some years ago, but I can't find it back.

@cartermp cartermp added the Bug label Aug 29, 2018
@cartermp cartermp added this to the Unknown milestone Aug 29, 2018
@cartermp cartermp modified the milestones: Unknown / not bug, Backlog May 23, 2019
@dsyme dsyme added the Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. label Aug 26, 2020
ScottHutchinson added a commit to ScottHutchinson/docs that referenced this issue Dec 24, 2020
cartermp pushed a commit to dotnet/docs that referenced this issue Dec 26, 2020
@dsyme dsyme added Area-Compiler-Syntax lexfilter, indentation and parsing and removed Area-Compiler labels Mar 31, 2022
@abelbraaksma
Copy link
Contributor

From the linked issue, there’s an open language suggestion that fixes this, here’s the rfc: https://github.com/fsharp/fslang-design/blob/main/RFCs/FS-1083-srtp-type-no-whitespace.md

@edgarfgp
Copy link
Contributor

@abelbraaksma Just tried with version 7 and this still happens. |So looks like the SRTP whitespace relaxation did not help here :(

@abelbraaksma
Copy link
Contributor

Thanks for trying it out. Fantomas often autocorrects such code, but it’s better if this could still be completely fixed, I think the language spec allows it.

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
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants