]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani: labels only in 'use' statement.
[ocean] / csrc / oceani.mdc
index a8653cc669adbe9ee21d894ecb9744e99b46ce66..f5983440c25ea87ef0dcae5489b70012f40d3e12 100644 (file)
@@ -1096,7 +1096,7 @@ list of in_scope names.
 
                        v = t->previous;
                        free_value(t->val);
-                       if (t->min_depth == 0)
+                       if (t->depth == 0)
                                // This is a global constant
                                free_exec(t->where_decl);
                        free(t);
@@ -2344,8 +2344,8 @@ link to find the primary instance.
                        /* This might be a label - allocate a var just in case */
                        v = var_decl(c, $1.txt);
                        if (v) {
-                               v->val = val_prepare(Tlabel);
-                               v->val.label = &v->val;
+                               v->val = val_prepare(Tnone);
+                               v->where_decl = $0;
                                v->where_set = $0;
                        }
                }
@@ -2408,6 +2408,9 @@ link to find the primary instance.
                                 v->where_decl, NULL, 0, NULL);
                        return v->val.type;
                }
+               if (v->val.type == Tnone && v->where_decl == prog)
+                       type_err(c, "error: variable used but not declared: %v",
+                                prog, NULL, 0, NULL);
                if (v->val.type == NULL) {
                        if (type && *ok != 0) {
                                v->val = val_prepare(type);
@@ -3387,6 +3390,14 @@ function.
                $0 = new_pos(binode, $1);
                $0->op = Use;
                $0->right = $<2;
+               if ($0->right->type == Xvar) {
+                       struct var *v = cast(var, $0->right);
+                       if (v->var->val.type == Tnone) {
+                               /* Convert this to a label */
+                               v->var->val = val_prepare(Tlabel);
+                               v->var->val.label = &v->var->val;
+                       }
+               }
        }$
 
 ###### print binode cases