Merge pull request #273 from aeternity/GH272-singleton_record_calldata_decode

Fix singleton record calldata decode + test
This commit is contained in:
Hans Svensson 2020-08-11 07:58:36 +02:00 committed by GitHub
commit ed5447e430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) ->
{tuple, [], [from_fate(Type, X)
|| {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))
when length(Fields) == tuple_size(Val) ->
{record, [], [ {field, [], [{proj, [], FName}], from_fate(FType, X)}

View File

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

View File

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