You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Sdk 2] Compiler does not fail if FSharp.Core is not referenced #3340
The compiler is always going to find an FSharp.Core.dll. With or without SDK magic. The Compiler has always had a last port of call where it looks in the directory containing the compiler binaries to load an FSharp.Core. And we ship an FSharp.Core.dll alongside the compiler.
The behavior is needed for the command line compile scenario: fsc program.fs and fsi scripts and the interactive fsi session, as well as, I expect, most apps that rely on the FCS.
@KevinRansom and that's great when you call the compiler manually - but not so great when the compiler gets called from the sdk.
Similar to --noframework, there needs to be a switch to disable this magic resolution ( I call it magic because it is not obvious from the user's point of view).
My concern is that if we enable DisableImplicitFSharpCoreReference by default in paket, then we end up with a lot of broken packages that do not reference FSharp.Core at all.
My second concern is that if we do not enable DisableImplicitFSharpCoreReference by default in paket, then we end up with a lot of packages that reference a wrong version of FSharp.Core.
We already have a switch it's called --simpleresolution, however, even that does this fallback behavior, and always has. I am reluctant to add yet another compiler switch
e.g. --reallyreallytrulysimpledonothingmagicatall
because I know that at some point someone will add code to make it do magic. Changing the current behavior will break some existing project, and
What we can do is this:
Add something to the SDK targets, that verifies that there is an FSharp.Core referenced in the msbuild target and fail if it doesn't find it.
Then when you build using an SDK target with the disabled flag. If there isn't a manual reference the sdk build will fail with an error.
If you like the idea open an issue, and we will look at how to solve it.
I think the existing flags all have more or less well defined behaviour and are orthogonal:
(someone please correct me if I am wrong)
--simpleresolution: don't manually resolve assembly identities like "System.ValueTuple" to the GAC or special folders, expect that the user passes the full path.
--noframework: don't automatically reference the latest installed .net framework, expect that the user passes all facades manually.
So a new switch --noimplicitfsharpcore would, in my opinion, be completely unrelated to the existing switches.
I'm okay with, building this into the SDK especially since you have the same issue with System.ValueTuple and perhaps any other framework assembly that holds types that may migrate to other contract assemblies eventually, that we may auto-reference.
And perhaps one day we can clean up all of the compiler referencing to a simple model. That is at least my hope ...
A check in the SDK would be better than nothing, and even if I can convince you to add the new fsc arg, it's probably easier to modify the sdk than to modify the compiler with regard to 15.3. =)
But that just feels a bit like a bandaid.
especially since you have the same issue with System.ValueTuple
Afaik the compiler does have special knowledge about a few types (e.g. it knows that System.Tuple moved from FSharp.Core to the mscorlib), but (again afaik) FSharp.Core is (with --noframework) the only thing that gets automatically referenced.
namespace testx
module Say =
let hello name =
let x = System.ValueTuple<int,int>(1, 2)
printfn "Hello %s" name
Microsoft (R)-Buildmodul, Version 15.3.406.54721 für .NET Core
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
C:\temp\testx\Library.fs(5,24): error FS0039: Der Wert, Konstruktor, Namespace oder Typ "ValueTuple" ist nicht definiert. Vielleicht möchten Sie eine der folgenden Bezeichnungen verwenden:� ValueType [C:\temp\testx\testx.fsproj]
Fehler beim Buildvorgang.
C:\temp\testx\Library.fs(5,24): error FS0039: Der Wert, Konstruktor, Namespace oder Typ "ValueTuple" ist nicht definiert. Vielleicht möchten Sie eine der folgenden Bezeichnungen verwenden:� ValueType [C:\temp\testx\testx.fsproj]
0 Warnung(en)
1 Fehler
Verstrichene Zeit 00:00:01.65
(Sorry for the german, The value, constructor, namespace or type "ValueTuple" is not defined.)
@0x53A everything about how the compiler resolves types is a band aid. I want to move to the model that nothing is resolved magically. However, we are a long way away from being able to do that ... Until then enforcing requirements in the build system is what we have.
I always thought --noframework disabled this magic stuff, is there a second switch to disable magic FSharp.Core resolution?
I thought this was the case as well. It would be worth checking previous versions of F# to see if this was the case and if something has changed here. (Specifically, I thought the compiler complained if you gave it an explicit "mscorlib.dll" without an explicit "FSharp.Core")
Certainly I would have no problem with --noframework having this behaviour. The whole point of --noframework is to turn off all the auto-referencing that is necessary for the current implementation of the F# scripting model, i.e. it is designed to get you to the simple world that @KevinRansom mentions.
Activity
0x53A commentedon Jul 16, 2017
I created a detailed build log, this is the relevant part:
Note how there is no reference to FSharp.Core.
I always thought
--noframeworkdisabled this magic stuff, is there a second switch to disable magic FSharp.Core resolution?KevinRansom commentedon Jul 17, 2017
@0x53A
The compiler is always going to find an FSharp.Core.dll. With or without SDK magic. The Compiler has always had a last port of call where it looks in the directory containing the compiler binaries to load an FSharp.Core. And we ship an FSharp.Core.dll alongside the compiler.
The behavior is needed for the command line compile scenario: fsc program.fs and fsi scripts and the interactive fsi session, as well as, I expect, most apps that rely on the FCS.
Kevin
forki commentedon Jul 17, 2017
fsc program.fsand fsi are completely different things than sdk and pack.KevinRansom commentedon Jul 17, 2017
How is that relevant?
0x53A commentedon Jul 17, 2017
@KevinRansom and that's great when you call the compiler manually - but not so great when the compiler gets called from the sdk.
Similar to
--noframework, there needs to be a switch to disable this magic resolution ( I call it magic because it is not obvious from the user's point of view).My concern is that if we enable
DisableImplicitFSharpCoreReferenceby default in paket, then we end up with a lot of broken packages that do not reference FSharp.Core at all.My second concern is that if we do not enable
DisableImplicitFSharpCoreReferenceby default in paket, then we end up with a lot of packages that reference a wrong version of FSharp.Core.KevinRansom commentedon Jul 17, 2017
0x53a.
We already have a switch it's called --simpleresolution, however, even that does this fallback behavior, and always has. I am reluctant to add yet another compiler switch
e.g. --reallyreallytrulysimpledonothingmagicatall
because I know that at some point someone will add code to make it do magic. Changing the current behavior will break some existing project, and
What we can do is this:
Add something to the SDK targets, that verifies that there is an FSharp.Core referenced in the msbuild target and fail if it doesn't find it.
Then when you build using an SDK target with the disabled flag. If there isn't a manual reference the sdk build will fail with an error.
If you like the idea open an issue, and we will look at how to solve it.
How does that sound?
Kevin
forki commentedon Jul 17, 2017
What's wrong with this issue here?
Doing it in the sdk is OK too
0x53A commentedon Jul 17, 2017
I think the existing flags all have more or less well defined behaviour and are orthogonal:
(someone please correct me if I am wrong)
--simpleresolution: don't manually resolve assembly identities like "System.ValueTuple" to the GAC or special folders, expect that the user passes the full path.--noframework: don't automatically reference the latest installed .net framework, expect that the user passes all facades manually.So a new switch
--noimplicitfsharpcorewould, in my opinion, be completely unrelated to the existing switches.KevinRansom commentedon Jul 17, 2017
I'm okay with, building this into the SDK especially since you have the same issue with System.ValueTuple and perhaps any other framework assembly that holds types that may migrate to other contract assemblies eventually, that we may auto-reference.
And perhaps one day we can clean up all of the compiler referencing to a simple model. That is at least my hope ...
0x53A commentedon Jul 17, 2017
A check in the SDK would be better than nothing, and even if I can convince you to add the new fsc arg, it's probably easier to modify the sdk than to modify the compiler with regard to 15.3. =)
But that just feels a bit like a bandaid.
Afaik the compiler does have special knowledge about a few types (e.g. it knows that System.Tuple moved from FSharp.Core to the mscorlib), but (again afaik) FSharp.Core is (with --noframework) the only thing that gets automatically referenced.
(Sorry for the german,
The value, constructor, namespace or type "ValueTuple" is not defined.)KevinRansom commentedon Jul 17, 2017
@0x53A everything about how the compiler resolves types is a band aid. I want to move to the model that nothing is resolved magically. However, we are a long way away from being able to do that ... Until then enforcing requirements in the build system is what we have.
dsyme commentedon Jul 18, 2017
I thought this was the case as well. It would be worth checking previous versions of F# to see if this was the case and if something has changed here. (Specifically, I thought the compiler complained if you gave it an explicit "mscorlib.dll" without an explicit "FSharp.Core")
Certainly I would have no problem with
--noframeworkhaving this behaviour. The whole point of--noframeworkis to turn off all the auto-referencing that is necessary for the current implementation of the F# scripting model, i.e. it is designed to get you to the simple world that @KevinRansom mentions.dsyme commentedon Aug 24, 2021
Closing out this old issue