bytedance / go-tagexpr

An interesting go struct tag expression syntax for field validation, etc.
Apache License 2.0
1.66k stars 142 forks source link

cycle struct cite cause stack over flow #23

Open chenchu2014 opened 3 years ago

chenchu2014 commented 3 years ago

type struct A {b B} type struct B {a A}

will cause stack over flow, think of cycle cite check?

andeya commented 3 years ago

which func?

chenchu2014 commented 3 years ago

github.com/bytedance/go-tagexpr@v2.7.2+incompatible/validator/default.go:16

andeya commented 3 years ago

But I can't reproduce it

type (
    Issue23A struct {
        b *Issue23B
        v int64 `vd:"$==0"`
    }
    Issue23B struct {
        a *Issue23A
        v int64 `vd:"$==0"`
    }
)

func TestIssue23(t *testing.T) {
    var data = &Issue23B{a: &Issue23A{b: new(Issue23B)}}
    err := vd.Validate(data)
    assert.NoError(t, err)
}
=== RUN   TestIssue23
--- PASS: TestIssue23 (0.00s)
PASS