WebSharper

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

1
2
3
4
5
6
7
8
9
    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
  • JankoA

    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.

  • github

    This topic has been closed.

  • ca-ta

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