Uh oh!
There was an error while loading. Please reload this page.
Allow parameter-less CustomOperation - #16475
Conversation
❗ Release notes required
|
vzarytovskii
commented
Dec 30, 2023
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? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nojaf
commented
Jan 2, 2024
The example looks off compared to https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html. |
vzarytovskii
commented
Jan 2, 2024
Right now, the following code openSystemtypeC()=[<CustomOperation("foo bar")>]member_.M()=()member_.Zero _ =()member_.Yield _ =()letc= 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? |
T-Gro
commented
Jan 2, 2024
Error has the problem with existing code (builder author, not consumer) compiling fine, warning at build time of the builder could work. |
vzarytovskii
commented
Jan 2, 2024
Diagnostic will only affect builder author, not consumer. So existing compiled builders should work fine (if they anyhow using custom operations with spaces inside). |
T-Gro
commented
Jan 2, 2024
It's just the unpleasant situation for a builder author to update .NET SDK, and suddenly getting a new error. |
vzarytovskii
commented
Jan 2, 2024
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. |
0101
commented
Jan 2, 2024
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 |
vzarytovskii
commented
Jan 2, 2024
Well, it seems that you can, in fact, call custom operations: openSystemtypeC()=[<CustomOperation("foo bar")>]member_.M(())=()member_.Zero _ =()member_.Yield _ =()letc= 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). |
vzarytovskii
commented
Jan 2, 2024
Actually, disregard my question about spaces in the CustomOperationAttribute, since code I wrote in the example is incorrect. |
vzarytovskii
commented
Jan 2, 2024
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 _ =() |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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 namestest, 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.