net*_*nel 0 types compiler-errors reason
我正在尝试理性并遇到一个我不明白的错误
这是我的代码:
let mult = (x:float, y:float):float => x * y;
Run Code Online (Sandbox Code Playgroud)
当我使用BuckleScript编译它时,我收到以下错误:
We've found a bug for you!
D:\1\bbl\orga\src\demo.re 1:40
1 Ôöé let mult = (a:float, b:float):float => a * b;
This has type:
float
But somewhere wanted:
int
You can convert a float to a int with int_of_float.If this is a literal, you want a number without a trailing dot (e.g. 20).
Run Code Online (Sandbox Code Playgroud)
我不明白为什么编译器会需要打开一个float到int这里
我的建议是删除类型,让推理处理它,它真的很好.
但是,如果您想保留特定类型,则需要更改运营商.你所拥有的是两个整数相乘.如果要将两个浮点数相乘,则将其更改为:
*
请注意,接线员就*.到*,表示浮点运算.
请在此处查看更多文档:https://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#1_Floatingpointarithmetic
| 归档时间: |
|
| 查看次数: |
91 次 |
| 最近记录: |