Closed
Description
I'm trying to compile a script using the JSON type provider with Fable. However, whenever I try to access an expression using a provided type an exception is thrown.
Repro steps
Try to compile the following script with Fable.
#r "../../../bin/FSharp.Data.dll"
open FSharp.Data
type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let simple = Simple.Parse(""" { "name":"Tomas", "age":4 } """)
simple.Age
Expected behavior
The AST is fully accessible and can be compiled to JS.
Actual behavior
When examining the tree and reaching simple.Age
, trying to match the expression against any of the active patterns in BasicPatterns
module results in the following error:
A call to 'FSharp.Data.Runtime.JsonValueOptionAndPath::get_Path(...)' could not be resolved
Stack trace:
at Microsoft.FSharp.Compiler.SourceCodeServices.ExprUtilsImpl.bindILMethodRefToSymbol (Microsoft.FSharp.Compiler.SourceCodeServices.cenv cenv, range m, Microsoft.FSharp.Compiler.AbstractIL.ILMethodRef ilMethRef) <0xd6f8410 + 0x0073f> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExprConvert.ConvExprPrim (Microsoft.FSharp.Compiler.SourceCodeServices.cenv cenv, Microsoft.FSharp.Compiler.SourceCodeServices.ExprTranslationEnv env, Microsoft.FSharp.Compiler.Expr expr) <0xd6ee7c8 + 0x009bf> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExprConvert.ConvExprPrimLinear (Microsoft.FSharp.Compiler.SourceCodeServices.cenv cenv, Microsoft.FSharp.Compiler.SourceCodeServices.ExprTranslationEnv env, Microsoft.FSharp.Compiler.Expr expr, Microsoft.FSharp.Core.FSharpFunc`2 contf) <0xd6f65f0 + 0x00463> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExprConvert.ConvExprPrim (Microsoft.FSharp.Compiler.SourceCodeServices.cenv cenv, Microsoft.FSharp.Compiler.SourceCodeServices.ExprTranslationEnv env, Microsoft.FSharp.Compiler.Expr expr) <0xd6ee7c8 + 0x00a1f> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExprConvert.ConvExprPrimLinear (Microsoft.FSharp.Compiler.SourceCodeServices.cenv cenv, Microsoft.FSharp.Compiler.SourceCodeServices.ExprTranslationEnv env, Microsoft.FSharp.Compiler.Expr expr, Microsoft.FSharp.Core.FSharpFunc`2 contf) <0xd6f65f0 + 0x00463> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExprConvert+ConvExprOnDemand@903.Invoke (Microsoft.FSharp.Core.Unit unitVar0) <0xd6ee758 + 0x0002f> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr.get_E () <0xd6ee710 + 0x00030> in <filename unknown>:0
at Microsoft.FSharp.Compiler.SourceCodeServices.BasicPatterns.|Call|_| (Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr e) <0xe089fa0 + 0x00017> in <filename unknown>:0
at FSI_0002+printDecls@48-10.Invoke (Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr _arg1) <0xe089e38 + 0x00013> in <filename unknown>:0
at FSI_0002.lookup (Microsoft.FSharp.Core.FSharpFunc`2 f, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr expr) <0xe089da8 + 0x00018> in <filename unknown>:0
at FSI_0002+printDecls@36.Invoke (Int32 i, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpImplementationFileDeclaration decl) <0xd6e6c28 + 0x0048b> in <filename unknown>:0
at Microsoft.FSharp.Collections.SeqModule.IterateIndexed[T] (Microsoft.FSharp.Core.FSharpFunc`2 action, IEnumerable`1 source) <0xd6e2180 + 0x000d0> in <filename unknown>:0
at FSI_0002.printDecls (System.String prefix, Microsoft.FSharp.Collections.FSharpList`1 decls) <0xd6e6a40 + 0x00067> in <filename unknown>:0
Known workarounds
None.
Related information
- Operating system: OSX El Capitán
- Branch: FSharp.Compiler.Service 3.0.0
- .NET Runtime, CoreCLR or Mono Version: Mono 4.4.0
- Editing Tools (e.g. Visual Studio Version): VS Code/Xamarin