From 19148dce964ae988dab3981c8d7365576fb4767b Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 14 Oct 2021 13:59:34 +1100 Subject: [PATCH] oceani: move ->prepare_type call (back) into val_alloc() This ensures it is called for struct fields as well. Signed-off-by: NeilBrown --- csrc/oceani-tests.mdc | 3 ++- csrc/oceani.mdc | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 46c1a09..e7e9f22 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -551,8 +551,9 @@ Time to test if structure declarations and accesses work correctly. ###### test: structs + const three ::= 3 struct foo - size:[3]number + size:[three]number name:string active:Boolean diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 7ff26c5..18e5930 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -537,6 +537,9 @@ Named type are stored in a simple linked list. Objects of each type are { struct value *ret; + if (t->prepare_type) + t->prepare_type(t); + ret = calloc(1, t->size); if (init) memcpy(ret, init, t->size); @@ -3366,9 +3369,6 @@ it is declared, and error will be raised as the name is created as v = v->merged; free_value(v->type, v->val); free(v->val); - if (v->type->prepare_type) - // FIXME is this the first usage of the type? - v->type->prepare_type(v->type); if (b->right) { right = interp_exec(b->right, &rtype); v->val = val_alloc(v->type, &right); -- 2.43.0