This file prompts:
Error at line 5: 72 function main may not use constrained output type (subrange or enumeration)
function main (choice: payload) returns (wolf, golds, cabbage, farmer: side);
Why it happens?
Some solutions please.
--farmer2.lus
type payload = enum { Empty, Wolf, Goat, Cabbage };
type side = enum { Left, Right };
function main(choice : payload) returns (wolf, goat, cabbage, farmer : side);
node testMain(choice : payload[2]) returns (wolf, goat, cabbage, farmer : side[2]);
var
wolf_0: side;
wolf_1: side;
golt_0: side;
golt_1: side;
cabbage_0: side;
cabbage_1: side;
farmer_0: side;
farmer_1: side;
let
wolf_0, golt_0, cabbage_0, farmer_0 = main(choice[0]);
wolf_1, golt_1, cabbage_1, farmer_1 = main(choice[1]);
wolf = [wolf_0, wolf_1];
goat = [goat_0, goat_1];
cabbage = [cabbage_0, cabbage_1];
farmer = [farmer_0, farmer_1];
tel;
This file prompts:
Error at line 5: 72 function main may not use constrained output type (subrange or enumeration)
function main (choice: payload) returns (wolf, golds, cabbage, farmer: side);
Why it happens?
Some solutions please.
--farmer2.lus
type payload = enum { Empty, Wolf, Goat, Cabbage };
type side = enum { Left, Right };
function main(choice : payload) returns (wolf, goat, cabbage, farmer : side);
node testMain(choice : payload[2]) returns (wolf, goat, cabbage, farmer : side[2]);
var
wolf_0: side;
wolf_1: side;
golt_0: side;
golt_1: side;
cabbage_0: side;
cabbage_1: side;
farmer_0: side;
farmer_1: side;
let
wolf_0, golt_0, cabbage_0, farmer_0 = main(choice[0]);
wolf_1, golt_1, cabbage_1, farmer_1 = main(choice[1]);
wolf = [wolf_0, wolf_1];
goat = [goat_0, goat_1];
cabbage = [cabbage_0, cabbage_1];
farmer = [farmer_0, farmer_1];
tel;