aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/types.zc
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/types.zc')
-rw-r--r--src/compiler/types.zc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/types.zc b/src/compiler/types.zc
index c643f0b..6dda110 100644
--- a/src/compiler/types.zc
+++ b/src/compiler/types.zc
@@ -497,8 +497,9 @@ int dtype() {
}
return 0;
}
-// the struct whose body or methods are being compiled, when it declares constants: a bare
-// name there is looked up as Struct.name before the global scope
+// the struct whose body or methods are being compiled: a bare name there is looked up as Struct.name
+// (a constant, or a static function called by its bare name) before the global scope, so the struct's
+// own wins over a global of the same name
char* mstruct;
// does a constant declaration start in a struct body? const NAME = e; const T NAME = e;
// (a field of a const type has no initializer, so the = tells them apart)
@@ -652,6 +653,7 @@ int kw_struct() {
}
accept(s_semi);
i = 0;
+ if (!gen) mstruct = n;
while (i < nm) { fn_method_compile = 1; methdef(n, mn[i], mq[i], mst[i], mty[i], mrt[i], mrg[i]); fn_method_compile = 0; i++; }
mdg = 0;
mstruct = msv;