相关疑难解决方法(0)

警告40的含义是什么:此记录...包含在当前范围内不可见的字段

请考虑以下代码:

module A =
  struct
    type r = { i : int; s: string }
  end

module B =
  struct
    type r = { i : int; s : string }
  end


let f (x : A.r) : B.r = match x with
    { i; s } -> { i = 2*i; s = "" }
Run Code Online (Sandbox Code Playgroud)

两个模块定义完全相同的记录.函数f将A记录转换为B记录.警告已在编译期间发出,但也可以交互显示.在ocaml cli上,似乎对f的调用完成了预期的事情:

# let x = f { i = 5; s = "ab" };;
Characters 10-29:
  let x = f { i = …
Run Code Online (Sandbox Code Playgroud)

ocaml

14
推荐指数
1
解决办法
2385
查看次数

标签 统计

ocaml ×1