-
Notifications
You must be signed in to change notification settings - Fork 847
Implement ToString on unions (RFC FS-1022) #1589
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
Conversation
|
Hi @colinbull, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
|
@colinbull, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
|
Normally we now try to generate augmentations in TypeChecker.fs/AugmentWithHashCompare. Doing this (generating TAST nodes) usually has benefits, because to F# the thing looks like a "normal" method for all other checks, and everything works just as if the user had written the code manually. However in this particular case I can't think of a specific reason why that would bring a benefit. But if you wanted to take a look at doing that in AugmentWithHashCompare it may end up being be better |
|
Yep, I certainly can do. I was initially looking at that, but was slightly On Tue, Oct 11, 2016 at 9:41 AM, Don Syme notifications@github.com wrote:
|
|
@colinbull Yeah. Since you have this in place already I'm inclined to think you should just keep it as is unless we can think of a specific reason why moving to generating TASTs is better for this case |
|
Apologies for the sort of newbie nature to this question, but I'm slightly confused by these failing tests. Basically I have added 3 modules to However when these tests are run for FSI_FILE, FS_OPT_PLUS_DEBUG and AS_DLL permutations fail with ERRORLEVEL -1073741571, 255 and 255 respectively which seems to be due to a StackOverflow exception. The thing I'm finding strange is this seems to work perfectly from both fsi when the type is entered and in a compiled assembly, I cannot replicate the error that the tests are showing. Now I'm sure there is something obviously wrong, but looking at the IL it looks pretty sound to my untrained eye, and the C# representation of the decompiled sources looks O.K as well, Any pointers on the best way to go about debugging this? |
|
@colinbull I did some poking around for this. I think the issue is that when it is compiled for Because of this difference in the I'm not sure why the CompilationMapping is different when compiled for for those modes, though they are equivalent when using KindMask, but maybe @dsyme can shed some light on that. Edit: That said modifying the IL and changing the CompilationMapping to the SumType, it still crashes, but with a visibility issue. I imagine that means that the CompilationMapping is just a symptom of something else... |
|
OK, so the fix to this is quiet simple, just declare the types in the @dsyme is this by design or is something else going on here? |
|
@colinbull I think you might want to try rebasing onto master instead of merging. Merging caused a lot of commits that weren't yours to show up in the changes. Also I don't think you need to commit the TestLibrary.dll. |
5bda2eb to
15511f5
Compare
|
what's the status? I'm REALLY looking forward to this |
|
Since the merge of the Roslyn stuff to the master I cannot build it anymore as I have been unable to get the install of |
|
Sigh. Ok then let's try something different. Can you please try to rebase your stuff on very old commit that still builds for you? Should not influence anything in this feature branch. On a different note: @cartermp we should always make sure that compiler build/edit experience works with current VS. VS Vnext is something that really only Microsoft cares about. Unfortunately we have discussion every single time before new VS release. |
|
Odd. I'm using Visual Studio 2015 and not having problems working on master... |
|
@colinbull Are you saying you can't build |
|
I had a similar issue, a git clean and rebuild of proto compiler helped in my case |
|
I haven't tried rebuilding the proto compiler. I'll give that a try, although I suspect it won't help looking at the build log (attached), apparently it is missing some references. See here. EDIT: Obviously I can add these references, but wondering whether I actually should |
|
@colinbull I thought I'd fixed that issue. Are you sync'd with master? thanks |
|
@dsyme I have just cloned a brand new repository and this error still persists. |
|
@colinbull Thanks. I can definitely see the problem. There is this incredibly annoying issue here: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSharp.Compiler.Server.Shared/AssemblyInfo.fs#L12 If you want to work around it you can just remove that attribute (it is only used for Visual Studio setup installing this DLL) or define CROSS_PLATFORM_COMPILER for that DLL It seems we don't do a CI build on a Windows machine with Visual Studio installed, I see if I can enable that and fix this issue by getting that DLL from some nuget package. |
|
@dsyme I tried to get this to build based on your suggestion but it still didn't work since the VS SDK assemblies aren't conditionally referenced. So to fix this, I have added these as conditional references; but to make sure the current build still works when those assemblies are present, I have made some other changes to the build. However having the assmeblies NuGetted is alot more transparent so if that is possible then I'll keep the changes I have local. Either way I have pushed the changes that fixed the build for me to colinbull@4e0a848 if they look good to you and NuGet-ing the assmeblies isn't possible. then I'll create an issue and corresponding PR with the fix. I'm just concerned I might mess up something even more subtle with this type of change. But the build now works for me :) |
|
@colinbull Can you try #1723 please and see it it builds for you with that fix. It uses nuget in the obvious way |
de6626c to
2f385e0
Compare
|
Uh so it's failing more than one single time? That's weird. Then it should be investigated |
|
@KevinRansom @dsyme I think this is ready for review now that it's all green. |
|
@colinbull Now that #2189 has been merged, to get rid of the conflict, you need to reset to |
|
@colinbull I will look at this over the weekend. a 34 file PR will require some time. Thanks Kevin |
|
OK cool, the majority of files are due to the impact the tostring augmentation had on the IL generation and thus the tests covering those. |
|
@dotnet-bot test this please |
KevinRansom
left a comment
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 looks good to me.
|
@dsyme Can you run your eyes over this please, it looks fine to me. Kevin |
|
🎉 |
|
Thanks for this work Kevin |
This is an implementation of RFC FS-1022.
The current implementation implements by default an override of
ToStringon Unions, only if no override has been defined previously. The implementation is somewhat naive at the minute and just usessprintf. As the RFC states it is possible to create a more optimised implementation of this since do, know the structure of the types within the union case, so we could avoid the reflection cost. However, I'm currently of the opinion that the extra complexity of this might not be worth it. As I would expect this to emit representations that where equivalent tosprintfso my gut feeling is that we would just be re-implementing a lot of the reflection logic, just in this case statically using the type definition. Moreover people can simply overrideToStringthemselves this if they wish to provide a more performant implementationThis is currently work in progress as there are some tests still failing in core04.