From 80645222ad965b6d1692755518cf4cdd396c1949 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Fri, 16 Dec 2022 16:52:54 +0300 Subject: [PATCH] Allow accessing records fields in toplevel consts --- src/aeso_ast_infer_types.erl | 1 - test/contracts/toplevel_constants.aes | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 2b3bc90..046e2aa 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -2059,7 +2059,6 @@ infer_expr(Env, {record, Attrs, Record, Update}) -> NewUpdate = [ check_record_update(Env, RecordType, Fld) || Fld <- Update ], {typed, Attrs, {record, Attrs, NewRecord, NewUpdate}, RecordType}; infer_expr(Env, {proj, Attrs, Record, FieldName}) -> - ban_when_const(Env), NewRecord = {typed, _, _, RecordType} = infer_expr(Env, Record), FieldType = fresh_uvar(Attrs), add_constraint([#field_constraint{ diff --git a/test/contracts/toplevel_constants.aes b/test/contracts/toplevel_constants.aes index ee3691f..f495fc2 100644 --- a/test/contracts/toplevel_constants.aes +++ b/test/contracts/toplevel_constants.aes @@ -33,6 +33,7 @@ contract C = let c21 = ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ : C let c22 = N.nsconst let c23 = c01 + let c24 = c11.name entrypoint f01() = c01 entrypoint f02() = c02 @@ -57,3 +58,4 @@ contract C = entrypoint f21() = c21 entrypoint f22() = c22 entrypoint f23() = c23 + entrypoint f24() = c24