I wasn't testing default initial values for struct fields, so of course
it didn't work.
Signed-off-by: NeilBrown <neil@brown.name>
struct foo
size:[three]number
name:string
- active:Boolean
+ active:Boolean = True
struct baz { a:number; b:Boolean; }
info[i].name = nm
info[i].size[0] = i*i
- info[i].active = nm == "jane"
+ if nm != "jane":
+ info[i].active = False
for i:=0; then i=i+1; while i < 4:
print info[i].name, info[i].active, info[i].size[0]
for (i = 0; i < type->structure.nfields; i++) {
struct value *v;
v = (void*) val->ptr + type->structure.fields[i].offset;
- val_init(type->structure.fields[i].type, v);
+ if (type->structure.fields[i].init)
+ dup_value(type->structure.fields[i].type,
+ type->structure.fields[i].init,
+ v);
+ else
+ val_init(type->structure.fields[i].type, v);
}
}