Allow accessing records fields in toplevel consts

This commit is contained in:
Gaith Hallak 2022-12-16 16:52:54 +03:00
parent 7d61d247f7
commit 80645222ad
2 changed files with 2 additions and 1 deletions

View File

@ -2059,7 +2059,6 @@ infer_expr(Env, {record, Attrs, Record, Update}) ->
NewUpdate = [ check_record_update(Env, RecordType, Fld) || Fld <- Update ], NewUpdate = [ check_record_update(Env, RecordType, Fld) || Fld <- Update ],
{typed, Attrs, {record, Attrs, NewRecord, NewUpdate}, RecordType}; {typed, Attrs, {record, Attrs, NewRecord, NewUpdate}, RecordType};
infer_expr(Env, {proj, Attrs, Record, FieldName}) -> infer_expr(Env, {proj, Attrs, Record, FieldName}) ->
ban_when_const(Env),
NewRecord = {typed, _, _, RecordType} = infer_expr(Env, Record), NewRecord = {typed, _, _, RecordType} = infer_expr(Env, Record),
FieldType = fresh_uvar(Attrs), FieldType = fresh_uvar(Attrs),
add_constraint([#field_constraint{ add_constraint([#field_constraint{

View File

@ -33,6 +33,7 @@ contract C =
let c21 = ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ : C let c21 = ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ : C
let c22 = N.nsconst let c22 = N.nsconst
let c23 = c01 let c23 = c01
let c24 = c11.name
entrypoint f01() = c01 entrypoint f01() = c01
entrypoint f02() = c02 entrypoint f02() = c02
@ -57,3 +58,4 @@ contract C =
entrypoint f21() = c21 entrypoint f21() = c21
entrypoint f22() = c22 entrypoint f22() = c22
entrypoint f23() = c23 entrypoint f23() = c23
entrypoint f24() = c24