mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Tighten struct field restrictions re pointers.
This commit is contained in:
1 parent
95391533b3
commit
0dd7aaf56c
1 file changed
+3
-8
+3
-8
@@ -382,14 +382,9 @@ func (c *Checker) checkFields(fields []*a.Node, banPtrTypes bool) error {
|
|||||||
if err := q.tcheckTypeExpr(f.XType(), 0); err != nil {
|
if err := q.tcheckTypeExpr(f.XType(), 0); err != nil {
|
||||||
return fmt.Errorf("%v in field %q", err, f.Name().String(c.tm))
|
return fmt.Errorf("%v in field %q", err, f.Name().String(c.tm))
|
||||||
}
|
}
|
||||||
if banPtrTypes {
|
if banPtrTypes && f.XType().HasPointers() {
|
||||||
for x := f.XType(); x.Inner() != nil; x = x.Inner() {
|
return fmt.Errorf("check: pointer-containing type %q not allowed for field %q",
|
||||||
if x.Decorator().Key() == t.KeyPtr {
|
f.XType().String(c.tm), f.Name().String(c.tm))
|
||||||
// TODO: implement nptr (nullable pointer) types.
|
|
||||||
return fmt.Errorf("check: ptr type %q not allowed for field %q; use nptr instead",
|
|
||||||
x.String(c.tm), f.Name().String(c.tm))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if dv := f.DefaultValue(); dv != nil {
|
if dv := f.DefaultValue(); dv != nil {
|
||||||
if f.XType().Decorator() != 0 {
|
if f.XType().Decorator() != 0 {
|
||||||
|
|||||||
Reference in new issue
Block a user