Skip to content

Commit

Permalink
gotypes: Handle named types in Component.Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
greatroar committed Mar 17, 2023
1 parent fc7bbb8 commit f7afc49
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion examples/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Struct struct {
Int8 int8
Uint16 uint16
Int32 int32
Uint64 uint64
Uint64 NamedUint64
Float32 float32
Float64 float64
String string
Expand All @@ -16,6 +16,8 @@ type Struct struct {
Complex128 complex128
}

type NamedUint64 uint64

// Sub is a sub-struct of Struct, to demonstrate nested datastructure accesses.
type Sub struct {
A uint64
Expand Down
2 changes: 1 addition & 1 deletion examples/args/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestFunctionsEqual(t *testing.T) {
{FieldInt8, func(s Struct) int8 { return s.Int8 }},
{FieldUint16, func(s Struct) uint16 { return s.Uint16 }},
{FieldInt32, func(s Struct) int32 { return s.Int32 }},
{FieldUint64, func(s Struct) uint64 { return s.Uint64 }},
{FieldUint64, func(s Struct) uint64 { return uint64(s.Uint64) }},
{FieldFloat32, func(s Struct) float32 { return s.Float32 }},
{FieldFloat64, func(s Struct) float64 { return s.Float64 }},
{FieldStringLen, func(s Struct) int { return len(s.String) }},
Expand Down
2 changes: 1 addition & 1 deletion gotypes/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewComponent(t types.Type, addr operand.Mem) Component {
}

func (c *component) Resolve() (*Basic, error) {
b := toprimitive(c.typ)
b := toprimitive(c.typ.Underlying())
if b == nil {
return nil, errors.New("component is not primitive")
}
Expand Down

0 comments on commit f7afc49

Please sign in to comment.