diff options
Diffstat (limited to 'src/compiler/expr.zc')
| -rw-r--r-- | src/compiler/expr.zc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/expr.zc b/src/compiler/expr.zc index c6d29c6..40de6ef 100644 --- a/src/compiler/expr.zc +++ b/src/compiler/expr.zc @@ -1014,7 +1014,9 @@ int primary() { return C_PLAIN; } s = source_lookup(n); - if (mstruct && !ginst) { ms = lookup(methname(mstruct, n)); if (ms >= 0 && skind[ms] == K_CONST) s = ms; } + // in a method of a struct a bare name is that struct's own constant or static function first, so it + // wins over a global (a top-level function or constant) of the same name + if (mstruct && !ginst) { ms = lookup(methname(mstruct, n)); if (ms >= 0 && (skind[ms] == K_CONST || (skind[ms] == K_FN && (sflag[ms] & F_STATIC)))) s = ms; } if (s < 0 && rt.eq_w(n, "new")) s = source_lookup(s_new); if (s >= 0) rs_put(toff, RS_SYM, rs_sym(s), s); if (s >= 0 && skind[s] == K_KW) { |
