mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32: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 {
|
||||
return fmt.Errorf("%v in field %q", err, f.Name().String(c.tm))
|
||||
}
|
||||
if banPtrTypes {
|
||||
for x := f.XType(); x.Inner() != nil; x = x.Inner() {
|
||||
if x.Decorator().Key() == t.KeyPtr {
|
||||
// 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 banPtrTypes && f.XType().HasPointers() {
|
||||
return fmt.Errorf("check: pointer-containing type %q not allowed for field %q",
|
||||
f.XType().String(c.tm), f.Name().String(c.tm))
|
||||
}
|
||||
if dv := f.DefaultValue(); dv != nil {
|
||||
if f.XType().Decorator() != 0 {
|
||||
|
||||
Reference in new issue
Block a user