Skip to content

[4.13 bug] %apply externals require an arrow type as first argument regardless of the actual type #10450

@kit-ty-kate

Description

@kit-ty-kate

The following test case fails with OCaml 4.13 but worked perfectly before:

module M : sig
  type t
  val empty : t
end = struct
  type t = unit -> unit
  let empty () = ()
end

external test : M.t -> unit -> unit = "%apply"

let () = test M.empty ()
$ ocamlc test.ml
File "test.ml", line 11, characters 14-21:
11 | let () = test M.empty ()
                   ^^^^^^^
Error: This expression has type M.t
       This is not a function; it cannot be applied.

M.t is an abstract type but internally a function, which to me should be valid. However OCaml 4.13 somehow treats it as a function and rejects this code with a rather cryptic error message.

Looking into the PRs merged in 4.13 so far, it looks like this was introduced in #10081 (cc @alainfrisch @garrigue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions