Ich habe Fehler bekam während den folgenden Code kompilierenReasonml Typ mit mehreren Argumenten, Fehler Ausnahme Failure ("n")
type shape =
| Circle int
| Square int
| Rectangle int int;
let myShape = Circle 10;
let area =
switch myShape {
| Circle r => float_of_int (r * r) *. 3.14
| Square w => float_of_int (w * w)
| Rectangle w h => float_of_int (w * h)
};
Js.log area;
Fatal error: exception Failure("nth")
ninja: build stopped: subcommand failed.
Wenn ich die Rectangle
ändern (int, int) Tuple, es Werke
type shape =
| Circle int
| Square int
| Rectangle (int, int);
let myShape = Circle 10;
let area =
switch myShape {
| Circle r => float_of_int (r * r) *. 3.14
| Square w => float_of_int (w * w)
| Rectangle (w, h) => float_of_int (w * h)
};
Js.log area;
Ist es nicht möglich, mehrere Argumente auf einem Daten Konstruktor zu haben?
dank
Ausgabe vorgelegt worden https://github.com/BuckleScript/bucklescript/issues/1822
Diese Ausnahme sieht wie ein Compilerfehler aus. –