aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/decl.zc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/decl.zc b/src/compiler/decl.zc
index e2c3613..bbde5ba 100644
--- a/src/compiler/decl.zc
+++ b/src/compiler/decl.zc
@@ -94,8 +94,12 @@ int prescan_maker() {
// the guess only makes the function compile as if declared .u; its body is then
// checked against that, so a wrong guess is an error, never a silent leak.
int prescan_owned(int self) {
- int depth = 0, n, k, found = 0, nown = 0; let owned[16];
+ int depth = 0, n, k, found = 0, nown = 0, decl = 0; let owned[16];
while (tk != T_EOF) {
+ // a declaration's name follows a type name, a *, let or a comma; a plain
+ // assignment (to a global, say) follows ; { or }
+ int was = decl;
+ decl = tk == T_ID || (tk == T_OP && (rt.eq_w(tv, "*") || rt.eq_w(tv, ",")));
if (is_op(s_lb)) depth++;
else if (is_op(s_rb)) { depth--; if (!depth) { next(); return found; } }
else if (tk == T_ID && rt.eq_w(tv, "return")) {
@@ -107,7 +111,7 @@ int prescan_owned(int self) {
}
continue;
}
- else if (tk == T_ID) {
+ else if (tk == T_ID && was) {
n = tv; peek();
if (pk_tk == T_OP && pk_tv == s_eq) {
next(); next();