Reject non-pointer optional fields
This change rejects non-pointer optional fields in the IDL. Although there is no reason this couldn't work, technically speaking, it's almost always certainly a mistake. Better to issue an error about it; in the future, we could consider making this a warning.
This commit is contained in:
parent
7b66ae2be5
commit
43bb3ec766
2 changed files with 11 additions and 5 deletions
|
@ -15,14 +15,14 @@ type VPC struct {
|
|||
// The allowed tenancy of instances launched into the VPC. "default" indicates that instances can be launched with
|
||||
// any tenancy, while "dedicated" indicates that any instance launched into the VPC automatically has dedicated
|
||||
// tenancy, unless you launch it with the default tenancy.
|
||||
InstanceTenancy InstanceTenancy `coco:"instanceTenancy,optional,replaces"`
|
||||
InstanceTenancy *InstanceTenancy `coco:"instanceTenancy,optional,replaces"`
|
||||
// Specifies whether DNS resolution is supported for the VPC. If true, the Amazon DNS server resolves DNS hostnames
|
||||
// for your instances to their corresponding IP addresses; otherwise, it does not. By default, the value is true.
|
||||
EnableDNSSupport bool `coco:"enableDnsSupport,optional"`
|
||||
EnableDNSSupport *bool `coco:"enableDnsSupport,optional"`
|
||||
// Specifies whether the instances launched in the VPC get DNS hostnames. If this attribute is true, instances in
|
||||
// the VPC get DNS hostnames; otherwise, they do not. You can only set enableDnsHostnames to true if you also set
|
||||
// the enableDnsSupport property to true. By default, the value is set to false.
|
||||
EnableDNSHostnames bool `coco:"enableDnsHostnames,optional"`
|
||||
EnableDNSHostnames *bool `coco:"enableDnsHostnames,optional"`
|
||||
}
|
||||
|
||||
type InstanceTenancy string
|
||||
|
|
|
@ -276,13 +276,19 @@ func (chk *Checker) CheckStructFields(t *types.TypeName, s *types.Struct,
|
|||
if opts.Out && !isres {
|
||||
ok = false
|
||||
cmdutil.Sink().Errorf(
|
||||
diag.Message("fidl %v.%v is marked `out` but is not a resource property",
|
||||
diag.Message("field %v.%v is marked `out` but is not a resource property",
|
||||
t.Name(), fld.Name()))
|
||||
}
|
||||
if opts.Replaces && !isres {
|
||||
ok = false
|
||||
cmdutil.Sink().Errorf(
|
||||
diag.Message("fidl %v.%v is marked `replaces` but is not a resource property",
|
||||
diag.Message("field %v.%v is marked `replaces` but is not a resource property",
|
||||
t.Name(), fld.Name()))
|
||||
}
|
||||
if _, isptr := fld.Type().(*types.Pointer); !isptr && opts.Optional {
|
||||
ok = false
|
||||
cmdutil.Sink().Errorf(
|
||||
diag.Message("field %v.%v is marked `optional` but is not a pointer in the IDL",
|
||||
t.Name(), fld.Name()))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue