-
Notifications
You must be signed in to change notification settings - Fork 803
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
Allow parameter-less CustomOperation #16475
Allow parameter-less CustomOperation #16475
Conversation
❗ Release notes required
|
Only took like a month to figure release notes automation out. @nojaf if you'll have a minute, could you please check the format and see if it needs and adjustment? |
The example looks off compared to https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html. |
Right now, the following code open System
type C() =
[<CustomOperation("foo bar")>]
member _.M() = ()
member _.Zero _ = ()
member _.Yield _ = ()
let c = C()
c { ``foo bar`` () }
c { ``foo bar`` } will yield the following compiler diagnostics:
Which is a bit confusing. @T-Gro @0101 What do you think if we disallow spaces in the parameters of the attribute, and in method names if attribute is parameter-less? Like introduce a new error (or warning) under preview version which will let user know that builder will compile but won't work? |
Error has the problem with existing code (builder author, not consumer) compiling fine, warning at build time of the builder could work. |
Diagnostic will only affect builder author, not consumer. So existing compiled builders should work fine (if they anyhow using custom operations with spaces inside). |
It's just the unpleasant situation for a builder author to update .NET SDK, and suddenly getting a new error. |
I don't think it's used anywhere (as it can't be utilised in any way), it will be under version flag as well. And it makes code more correct. I'm fine with warning as well. |
I don't think it's the space, I see the same error even without it. Can we make it work? Or just give diagnostic that tells you to write |
Well, it seems that you can, in fact, call custom operations: open System
type C() =
[<CustomOperation("foo bar")>]
member _.M(()) = ()
member _.Zero _ = ()
member _.Yield _ = ()
let c = C()
c { ``foo bar`` } compiles just fine, so we can't disallow it. I will just add the check for the new case (parameterless constructor). |
Actually, disregard my question about spaces in the CustomOperationAttribute, since code I wrote in the example is incorrect. |
…github.com/vzarytovskii/fsharp into custom-operation-parameterless-constructor
Ok, this is ready, I decided not to put [<CustomOperation>]
member _.``foo bar`` _ = () It will work exactly the same way it works now with [<CustomOperation("foo bar")>]
member _.FooBar _ = () |
Description
Implements fsharp/fslang-suggestions#1250
I can't think of the need of putting it under language version, since if new fslib is used with old compiler, said compiler will be unable to produce warning that new attribute constructor won't have any effect
Checklist
Addthis is allowed now, so we'll allow it in the new attribute.Quoted method names
test, disallow if neededAdd operators methodsirrelevant, since operators are static methods.Add RFC (does this need an RFC?)this doesn't need an RFC, since it's a very minor change.Disallow empty string as name (allowed now, but unusable, should it be an equivalent of unit constructor?)empty name is the equivalent of parameterless attribute.