X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani.mdc;h=a421167632746e9525716f96e3729983ff8022a4;hp=e3c8291572d9d82089c3f74538d2c5406bf86050;hb=0897423423ea2704abdfd35dc58065d12d9f7386;hpb=617cc1dc6d34f5cdd64758419322fc1165d74868 diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index e3c8291..a421167 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -2771,6 +2771,10 @@ because it really is the same variable no matter where it appears. When a variable is used, we need to remember to follow the `->merged` link to find the primary instance. +When a variable is declared, it may or may not be given an explicit +type. We need to record which so that we can report the parsed code +correctly. + ###### exec type Xvar, @@ -2780,6 +2784,9 @@ link to find the primary instance. struct variable *var; }; +###### variable fields + int explicit_type; + ###### Grammar $TERM : :: @@ -2824,6 +2831,7 @@ link to find the primary instance. v->where_decl = $0; v->where_set = $0; v->type = $explicit_type = 1; } else { v = var_ref(c, $1.txt); $0->var = v; @@ -2842,6 +2850,7 @@ link to find the primary instance. v->where_set = $0; v->type = $constant = 1; + v->explicit_type = 1; } else { v = var_ref(c, $1.txt); $0->var = v; @@ -4031,13 +4040,13 @@ it is declared, and error will be raised as the name is created as print_exec(b->left, indent, bracket); if (cast(var, b->left)->var->constant) { printf("::"); - if (v->where_decl == v->where_set) { + if (v->explicit_type) { type_print(v->type, stdout); printf(" "); } } else { printf(":"); - if (v->where_decl == v->where_set) { + if (v->explicit_type) { type_print(v->type, stdout); printf(" "); }