Fix singleton record calldata decode + test

This commit is contained in:
Hans Svensson 2020-08-10 16:35:37 +02:00
parent 6b60fde2df
commit db4de5d926
3 changed files with 8 additions and 0 deletions

View File

@ -95,6 +95,8 @@ from_fate({tuple_t, _, Types}, ?FATE_TUPLE(Val))
when length(Types) == tuple_size(Val) -> when length(Types) == tuple_size(Val) ->
{tuple, [], [from_fate(Type, X) {tuple, [], [from_fate(Type, X)
|| {Type, X} <- lists:zip(Types, tuple_to_list(Val))]}; || {Type, X} <- lists:zip(Types, tuple_to_list(Val))]};
from_fate({record_t, [{field_t, _, FName, FType}]}, Val) ->
{record, [], [{field, [], [{proj, [], FName}], from_fate(FType, Val)}]};
from_fate({record_t, Fields}, ?FATE_TUPLE(Val)) from_fate({record_t, Fields}, ?FATE_TUPLE(Val))
when length(Fields) == tuple_size(Val) -> when length(Fields) == tuple_size(Val) ->
{record, [], [ {field, [], [{proj, [], FName}], from_fate(FType, X)} {record, [], [ {field, [], [{proj, [], FName}], from_fate(FType, X)}

View File

@ -113,6 +113,7 @@ compilable_contracts() ->
{"funargs", "traffic_light", ["Pantone(12)"]}, {"funargs", "traffic_light", ["Pantone(12)"]},
{"funargs", "tuples", ["()"]}, {"funargs", "tuples", ["()"]},
%% TODO {"funargs", "due", ["FixedTTL(1020)"]}, %% TODO {"funargs", "due", ["FixedTTL(1020)"]},
{"funargs", "singleton_rec", ["{x = 1000}"]},
{"variant_types", "init", []}, {"variant_types", "init", []},
{"basic_auth", "init", []}, {"basic_auth", "init", []},
{"address_literals", "init", []}, {"address_literals", "init", []},

View File

@ -45,3 +45,8 @@ contract FunctionArguments =
entrypoint due(t : Chain.ttl) = entrypoint due(t : Chain.ttl) =
true true
record singleton_r = { x : int }
entrypoint singleton_rec(r : singleton_r) =
r.x