compiler: properly set extended type name for unnamed structs

After the struct was registered as "unnamed", it has the own unique name.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2023-05-25 18:45:59 +03:00
parent 0195aae824
commit 6379bcc15a
2 changed files with 8 additions and 16 deletions

View file

@ -386,10 +386,12 @@ func (c *codegen) scAndVMTypeFromType(t types.Type, exts map[string]binding.Exte
over.TypeName = "map[" + t.Key().String() + "]" + over.TypeName
return smartcontract.MapType, stackitem.MapT, over, et
case *types.Struct:
var extName string
if isNamed {
over.Package = named.Obj().Pkg().Path()
over.TypeName = named.Obj().Pkg().Name() + "." + named.Obj().Name()
_ = c.genStructExtended(t, over.TypeName, exts)
extName = over.TypeName
} else {
name := "unnamed"
if exts != nil {
@ -398,11 +400,14 @@ func (c *codegen) scAndVMTypeFromType(t types.Type, exts map[string]binding.Exte
}
_ = c.genStructExtended(t, name, exts)
}
// For bindings configurator this structure becomes named in fact. Its name
// is "unnamed[X...X]".
extName = name
}
return smartcontract.ArrayType, stackitem.StructT, over,
&binding.ExtendedType{ // Value-less, refer to exts.
Base: smartcontract.ArrayType,
Name: over.TypeName,
Name: extName,
}
case *types.Slice: