Skip to content
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

Moving a record to a separate file causes weird error messages #1038

Closed
jpalmer opened this issue Jan 1, 2019 · 1 comment
Closed

Moving a record to a separate file causes weird error messages #1038

jpalmer opened this issue Jan 1, 2019 · 1 comment

Comments

@jpalmer
Copy link

jpalmer commented Jan 1, 2019

So I created a record type for a simple 2d vector:

type Vector = 
        {
            x : double;
            y : double;
        }
        static member FromPolar r theta = {x = r * cos(theta); y = r * sin(theta)}
        member x.Length = x.x*x.x+x.y*x.y |> sqrt    
        member x.Scale l = 
            let mylen = x.Length
            let scale = l / mylen
            {x=x.x*scale;y=x.y*scale}

When this is in the same file as where it is used, everything is fine.

I then copied the same code into a separate file to tidy up the code.

At this point I got lots of errors like this:

WebSharper error FS9001: Unrecognized member of F# record type:

This could be fixed by adding [<JavaScript>] annotations to the members, but the error message should really be improved for this case

@Jand42
Copy link
Member

Jand42 commented Jan 3, 2019

F# record, union and exception types are treated specially by WebSharper, because the F# compiler itself generates extra members (not visible from F#, but they are from C# also some TPs might call them), so an extra code path handles translating their members after standard class member lookup fails.
But I do agree that some error handling standardization would be nice, for example falling back to the standard "Method name not found in JavaScript compilation" error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants