I'm deploying an F# app to heroku as a script, and I'm having very strange problems. I'm getting the following error in the cases indicated below, but not the others:
System.TypeLoadException: Could not load type 'FSI_0007+Test[]' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x410a5830 + 0x000b7> in :0
Error case:
type Test = { Test: string }
printfn "%A" [|{Test = "test"}|] <--- error here
Working cases:
printfn "%A" [|"test"|]
type Test = { Test: string }
printfn "%A" {Test = "test"}
printfn "%A" [{Test = "test"}]
So it appears that I can't put records in arrays, but I can put any built-in types in arrays. Also, I can put records in lists. And records by themselves are fine.
Why does the combination of records plus arrays cause errors?
I'm using the buildpack here: https://github.com/SuaveIO/mono-script-buildpack
which uses mono-4.4.2.11.
It doesn't happen with local fsi in visual studio.
[|and the start-of-record operator{? It might be that something is parsing the three characters[|{incorrectly as a single token instead of two tokens. If so, then writing[| {...} |]should work around the parsing bug. - rmunn