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

F# inner generics #642

Closed
cata opened this issue Jan 20, 2017 · 2 comments
Closed

F# inner generics #642

cata opened this issue Jan 20, 2017 · 2 comments

Comments

@cata
Copy link
Contributor

cata commented Jan 20, 2017

WebSharper 4 fails to compile the following valid F# code, with
"Failed to resolve generic parameter: b, found: a":

    let span pred l =
        let rec loop l cont =
            match l with
            | [] -> ([],[])
            | x::[] when pred x -> (cont l, [])
            | x::xs when not (pred x) -> (cont [], l)
            | x::xs when pred x -> loop xs (fun rest -> cont (x::rest))
            | _ -> failwith "Unrecognized pattern"
        loop l id
@Jand42
Copy link
Member

Jand42 commented Feb 1, 2017

Thanks for the report. In your sample, you can remove inner generics by a type annotation (cont: 'a list -> 'a list)

Generally, compiler could be improved that inner generic type parameters do not give an error, only when a macro would need it (when translation depends on the type), and then give a better error to move the function to a top level [<Inline>] for proper generic use.

@Jand42 Jand42 changed the title F# compilation: Incorrect type inferrence F# inner generics Feb 1, 2017
@Jand42 Jand42 closed this as completed in 41dd922 Feb 10, 2017
@cata
Copy link
Contributor Author

cata commented Jun 17, 2017

Thanks for the fix!
Sorry for the belated response, I somehow missed your reply.

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

No branches or pull requests

2 participants