-
Notifications
You must be signed in to change notification settings - Fork 825
[WIP] [FS-1003] Nameof operator reimplementation #2290
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
[WIP] [FS-1003] Nameof operator reimplementation #2290
Conversation
Conflicts: src/fsharp/FSComp.txt src/fsharp/FSharp.Core.Unittests/SurfaceArea.Silverlight.2.0.fs src/fsharp/FSharp.Core.Unittests/SurfaceArea.net20.fs src/fsharp/PostInferenceChecks.fs src/fsharp/TastOps.fs src/fsharp/TcGlobals.fs
This reverts commit 529cc6f.
This reverts commit 223d313. Conflicts: tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAppliedFunction.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAsAFunction.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfDictLookup.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntConst.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntegerAppliedFunction.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfParameterAppliedFunction.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfPartiallyAppliedFunction.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfStringConst.fs tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfWithPipe.fs
This looks promising. Please keep us posted about progress. |
src/fsharp/TypeChecker.fs
Outdated
| SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) when not (isNil idents) -> | ||
match expr with | ||
// `nameof` operator | ||
| ApplicableExpr (_, Expr.App(Expr.Const(Const.String("nameof"), _, _), _, _, _, _), _) -> // no idea really what shape we should match on here, will check in debugger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is technically a breaking change when user-defined function nameof
exists in the scope. I think it should resolve the name and only treat it as nameof
operator if it it was resolved to intrinsic from FSharp.Core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladima thanks! Any point how to do it? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladima I think I've found out the solution.
|
❤️ |
This is really cool :) |
Yeah looks much better than my original implementation. Next step would be tests for doing this in attributes. |
it raises a proper error if applicated to non (Long)Ident arg
@forki looks like it already works in attributes: I haven't checked the generated IL though. |
@vasily-kirichenko, what is the value of |
@smoothdeveloper no, it returns "foo". I think that's how it's supposed to work. |
That will give some surprise for those doing reflection, but yes I agree it is expected behaviour. We will need |
The problem: currently we can use
So we should restrict places where |
The above's been fixed. |
All cases from the list at the bottom of the RFC https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1003-nameof-operator.md work, except the following two:
I don't think we should support the last case at all. @dsyme any points where to fix the case with pattern matching? I think it's quite important. |
(I'm going to hold off reviewing this and the RFC until VS20117 RTM is done and dusted if that's ok) |
@vasily-kirichenko, well, it would have been an easy resolution for what I recently encountered with running certain tests, see #3632, but I'd understand, one swallow doesn't make it Spring (Dutch proverb ;)). |
@vasily-kirichenko That's just not true - many users (including myself) would love for this to be implemented. It's very useful in certain types of applications. |
I consider this to be fundamental. Therefor I think there isn't any argument against implementing it. |
@realvictorprm, I think that this PR was close to being finished by @vasily-kirichenko. I'd be interested to understand the current limitations better and why they aren't resolvable (could someone elaborate with an example perhaps?), or whether we can live with those limitations (F# has more limitations when it comes to full support of whatever C# can do). Sometimes covering 99% of all common cases is good enough, even more so if the other 1% can be worked around. Besides, it would be a waste to see all this work gone for naught. |
Look @vasily-kirichenko and myself tried to get it in (#13 and #908). It looks like super trivial feature but it has many many edge cases. What it needs is someone who goes through all the cases and makes a list which shows what is implemented and what not. Then @dsyme can decide if it is enough |
(first version is over two years old) |
This is not true
This is true |
@dsyme, @cartermp, @vasily-kirichenko, I'm trying to cut down the number of inactive PR's on our repo. This seems to be quite dead. I think the best thing is to close it, and let someone emerge who wants this feature drive it to completion. It has hung around without a concerted efforted for about 3 years now. What do you think? Kevin |
So, Microsoft does not want to drive it? Why it wanted to drive the Span feature, but does not want to do this one? Who decides? |
the span feature priority is irrelevant to this discussion. |
I could close this PR, as I did before, but you guys love to reopen it, so feel free to close it yourself. |
Okay I am closing this PR. I have created a branch: |
Is this feature complete? |
@xperiandri No, it needs reviving, rebasing, and taking over the finish line. There's a venn diagram of
and it's a slim intersection I believe. |
This comment has been minimized.
This comment has been minimized.
From a technical standpoint, the remaining work here is to handle:
|
Revamped implementation at #6325 @vasily-kirichenko @forki Thank you for your work on this RFC so far. |
Implementation of RFC FS-1003