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
Hi. I have Visual Studio Community 2013 Update 4 and 2015 RC on my system. While I was experimenting with F# 4.0, I encountered a problem with the new F# Interactive (v14.0.22810.0).
I did my best to isolate the problem into a minimal example. Here are the steps to reproduce:
Compile an F# library with the code
namespaceLibrary1moduleTest =let inlineinit1 n f = Array.init n f
letinit2 n f = Array.init n f
error FS0193: The module/namespace 'ErrorStrings' from compilation unit 'FSharp.Core' did not contain the val '{MemberParentMangledName = null;
MemberIsOverride = false;
LogicalName ="InputMustBeNonNegativeString";
TotalArgCount = 0;}'
whereas if you run it with F# Interactive 12.0.30815.0 it runs fine:
vala:float []=[|4.0;4.0;4.0;4.0|]
Here is some extra information:
If you call Test.init2, which has the same type with Test.init1, with F# Interactive 14.0.22810.0, there is no error and it runs fine. So, there is something to do with inline.
When you call Test.init1 from an F# console application
openLibrary1[<EntryPoint>]letmain argv =leta= Test.init1 4(fun _ ->4.)
printfn "%A" a
there is no error. So, the error is about F# Interactive.
When you compile the library code targeting FSharp.Core version 4.4.0.0, there is no error with F# Interactive 14.0.22810.0. So, this is a backward compatibility problem of the new F# Interactive with existing libraries compiled for FSharp.Core 4.3.1.0, I think.
This commit broke the binary compatibility of FSharp.Core: 52a7252
because the "module let" bindings were changed to "static member" bindings, and as far as F# metadata is concerned these are different. This obviously needs to be fixed for FSharp.Core 4.4.0.0.
These items are referred to in the inlined implementations of Array.init and other functions.
that commit was mine, so i think i should help 😄 , i'll fix this
Possible fix:
revert the old ErrorStrings module (backward compatibility).
add the static methods as functions in ErrorStrings module (or another module like Resources maybe? so we can reuse it for all the FSharp.Core resources if needed? )
But @dsyme can you help me to understand better the problem?
The root problem i think is: FSharp.Core.SR.resources is private/internal, so functions like FSharp.Core.SR.resources.GetString or SR.GetString(SR.arrayWasEmpty) etc, cannot be inlined, but some methods require it ( like average ) so we use a public wrapper ErrorStrings
That's ok, we can inline some functions, but not others unless we wrap the (SR.GetString(SR.arrayWasEmpty) as functions inside ErrorStrings.
The problem is:
Currently is difficult to inline more functions, because we break backward compatibility each time (like this bug).
If we add a new functions in ErrorStrings, reference the old version break for a simple refactoring (and maybe is a good perf improvement like an inline).
Maybe is already discussed before but cant we make a wrapper of FSharp.Core.SR.resources public instead? And use inlined functions for type safety access of resource strings?
inside the code we can do Resources.arrayWasEmpty () and that is compiled as SR.resourceManager.GetString("arrayWasEmpty", System.Globalization.CultureInfo.CurrentUICulture)
Another options is to use a GetString: string -> Culture option -> string wrapper instead to expose the ResourceManager class, but dont know, localization and resources are complicated.
Activity
dsyme commentedon Jun 6, 2015
@gbaydin - thank you for this timely bug report.
This commit broke the binary compatibility of FSharp.Core: 52a7252
because the "module let" bindings were changed to "static member" bindings, and as far as F# metadata is concerned these are different. This obviously needs to be fixed for FSharp.Core 4.4.0.0.
These items are referred to in the inlined implementations of Array.init and other functions.
enricosada commentedon Jun 8, 2015
that commit was mine, so i think i should help 😄 , i'll fix this
Possible fix:
Resourcesmaybe? so we can reuse it for all the FSharp.Core resources if needed? )But @dsyme can you help me to understand better the problem?
The root problem i think is:
FSharp.Core.SR.resourcesis private/internal, so functions likeFSharp.Core.SR.resources.GetStringorSR.GetString(SR.arrayWasEmpty)etc, cannot be inlined, but some methods require it ( likeaverage) so we use a public wrapperErrorStringsThat's ok, we can inline some functions, but not others unless we wrap the
(SR.GetString(SR.arrayWasEmpty)as functions insideErrorStrings.The problem is:
Currently is difficult to inline more functions, because we break backward compatibility each time (like this bug).
If we add a new functions in ErrorStrings, reference the old version break for a simple refactoring (and maybe is a good perf improvement like an inline).
Maybe is already discussed before but cant we make a wrapper of FSharp.Core.SR.resources public instead? And use inlined functions for type safety access of resource strings?
inside the code we can do
Resources.arrayWasEmpty ()and that is compiled asSR.resourceManager.GetString("arrayWasEmpty", System.Globalization.CultureInfo.CurrentUICulture)Another options is to use a
GetString: string -> Culture option -> stringwrapper instead to expose the ResourceManager class, but dont know, localization and resources are complicated.