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

Compiler issue: unexpected error when compiling an abstract generic method #18228

Closed
xloggr opened this issue Jan 11, 2025 · 3 comments
Closed

Comments

@xloggr
Copy link

xloggr commented Jan 11, 2025

F# compiler generates an unexpected error when building code containing an abstract generic method declaration. Similar non-generic code compiles with no errors.

Here's an example:

Non-generic version - compiles with no errors:

type IMyInterface =
  abstract member Sort: int list -> int list

Generic version

type IMyInterface =
  abstract member Sort<'T>: 'T list -> 'T list

fails to compile producing the following (somewhat cryptic) errors:

[FS0035] This construct is deprecated: ':' is not permitted as a character in operator names and is reserved for future use
[FS0010] Unexpected quote symbol in member definition. Expected ':' or other token.
[FS0010] Unexpected keyword 'type' in implementation file

To make the code compile I had to add a space before the colon:

type IMyInterface() =
  abstract member Sort<'T> : 'T list -> 'T list
  //   note the space     ^

It's inconsistent with the non-generic version which compiles with or without a space before the colon.
Seems to be a grammar definition issue...

Related information

  • OS: Ubuntu 24.04
  • .NET: 8.0.11
  • Editing Tools: JetBrains Rider
@edgarfgp
Copy link
Contributor

I remember fixing this at some point in NET8. You can try SDK 8.0.404 to see if the fix made there.

@xloggr
Copy link
Author

xloggr commented Jan 11, 2025

You're right, its fixed in 8.0.404 - thank you!

@edgarfgp
Copy link
Contributor

Closing this as it was fixed by #15923

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants