-
Notifications
You must be signed in to change notification settings - Fork 123
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
How to read the AST with provided types #568
Comments
UPDATE: I'm using a simple script to inspect the AST. I've noticed when this script is not in the same path as the file containing the code above I can actually read the AST, but it gets converted to exception raising. Both
I guess this is because the |
I cant tell from a quick review of the compiler code, I reckon debugging |
I replaced the FSharp.Compiler.Service reference with a custom build in Debug mode. However now when I try to parse the script I get the following error: In any case, I just tried with a very simple Type Provider and it worked so it might be not a problem with type providers per se but something else. I'll try to investigate more. |
I narrowed down the problem. It seems to happen when code from the BCL or from another library is called in the quotations. For example, if I have the following provider:
This works. But if I replace
Interestingly, calling methods from FSharp.Core (e.g. |
I have also seen that some IL method calls produced by type providers are not yet resolved correctly to their F# method symbols. These include:
However these are all handled correctly when creating quotation AST for ReflectedDefinition. Of course the |
There is a comment in the Expr.fs code that mentions curried args may not
be represented properly.
|
Closing the issue for now. I'm solving the issue for Fable by emitting Fable's AST directly from the Type Provider. The disadvantage is the TP must be explicitly made for Fable, but most of the current ones would have required special treatment anyway, so it should be fine. |
@alfonsogarciacaro Thanks for the update. I'll reopen to keep this issue active as we need to fix the problem. For erasing providers you should be able to read the TAST correctly. |
remove things irrelevant to build
My pull request fixes multiple kinds of failures that I could find.
There is a commented out failing test where F# type checking itself fails (same with current fsc.exe) |
Fix #568: recognize provided expressions
@dsyme I've tried to compile a type provider using the latest version of FCS but I'm still experiencing the same issue reported on top. Should we reopen the issue? |
@alfonsogarciacaro WebSharper 4 could translate your snippet: http://try.websharper.com/snippet/JankoA/00009T It uses FCS 6.0.2, but still version 2.2.5 of FSharp.Data, I will test updating that too. |
Newer FSharp.Data fails. One change is that it is including assembly for redirection for multitargeting. |
@Jand42 Thanks a lot for the info! As you say, trying to read the snippet AST with my simple script fails, but if I try to compile it directly with Fable works (well, it doesn't finish compilation because there's no replacement for I'm closing the issue again, sorry for the trouble! 😅 I'll try to make the provider work with Fable and if I find another problem along the way, I'll report it. Thanks again for your help! |
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.
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 inBasicPatterns
module results in the following error:A call to 'FSharp.Data.Runtime.JsonValueOptionAndPath::get_Path(...)' could not be resolved
Stack trace:
Known workarounds
None.
Related information
The text was updated successfully, but these errors were encountered: