]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani-tests: include failing test in valgrind testing
[ocean] / csrc / oceani.mdc
index 43616ec5be39b65fe3534a5e4356a70dcb445d9b..0334af198c9656e7f261beb6e773c838aeda2a8a 100644 (file)
@@ -261,9 +261,10 @@ structures can be used.
                        free(s);
                        s = t;
                }
-               if (!context.parse_error) {
-                       ## free global vars
-               }
+               // FIXME parser should pop scope even on error
+               while (context.scope_depth > 0)
+                       scope_pop(&context);
+               ## free global vars
                ## free context types
                ## free context storage
                exit(context.parse_error ? 1 : 0);
@@ -1875,9 +1876,10 @@ with a const size by whether they are prepared at parse time or not.
                t->array.vsize = NULL;
                if (number_parse(num, tail, $2.txt) == 0)
                        tok_err(c, "error: unrecognised number", &$2);
-               else if (tail[0])
+               else if (tail[0]) {
                        tok_err(c, "error: unsupported number suffix", &$2);
-               else {
+                       mpq_clear(num);
+               } else {
                        t->array.size = mpz_get_ui(mpq_numref(num));
                        if (mpz_cmp_ui(mpq_denref(num), 1) != 0) {
                                tok_err(c, "error: array size must be an integer",
@@ -3915,6 +3917,7 @@ it is declared, and error will be raised as the name is created as
                                type_err(c,
                                         "Variable declared with no type or value: %v",
                                         $1, NULL, 0, NULL);
+                               free_var($1);
                        } else {
                                $0 = new(binode);
                                $0->op = Declare;
@@ -4675,11 +4678,12 @@ searching through for the Nth constant for decreasing N.
                        v->where_set = var;
                        var->var = v;
                        v->constant = 1;
+                       v->global = 1;
                } else {
-                       v = var_ref(c, $1.txt);
+                       struct variable *vorig = var_ref(c, $1.txt);
                        tok_err(c, "error: name already declared", &$1);
                        type_err(c, "info: this is where '%v' was first declared",
-                                v->where_decl, NULL, 0, NULL);
+                                vorig->where_decl, NULL, 0, NULL);
                }
                do {
                        ok = 1;
@@ -4754,8 +4758,12 @@ is a bit more interesting at this level.
                        name->type->function.return_type = ret;
                        global_alloc(c, name->type, name, &fn);
                        var_block_close(c, CloseSequential, code);
-               } else
+               } else {
+                       free_binode(args);
+                       free_type(ret);
+                       free_exec(code);
                        var_block_close(c, CloseSequential, NULL);
+               }
                return name;
        }