Skip to content

Commit

Permalink
fix a deadloop when parsing variable like a.b.c
Browse files Browse the repository at this point in the history
  • Loading branch information
huandu committed Jul 28, 2023
1 parent dd9708b commit 8f6fe44
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ module github.com/huandu/go-assert

go 1.13

require (
github.com/davecgh/go-spew v1.1.1
)
require github.com/davecgh/go-spew v1.1.1
9 changes: 0 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
6 changes: 5 additions & 1 deletion internal/assertion/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,11 @@ func getValueInterface(v reflect.Value) interface{} {
num := v.NumField()

for i := 0; i < num; i++ {
st.Field(i).Set(reflect.ValueOf(getValueInterface(v.Field(i))))
field := st.Field(i)

if field.CanSet() {
field.Set(reflect.ValueOf(getValueInterface(v.Field(i))))
}
}

return st.Interface()
Expand Down
2 changes: 1 addition & 1 deletion internal/assertion/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func IsVar(expr ast.Expr) bool {

for {
if sel, ok := x.(*ast.SelectorExpr); ok {
x = sel
x = sel.X
} else {
break
}
Expand Down

0 comments on commit 8f6fe44

Please sign in to comment.