shithub: mc

Download patch

ref: 00e81c21f68c73403e42d08a6d5d955aa303cefd
parent: b37fc330005640f45c9691fe256993cb0b4e3e6c
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Jul 3 19:21:19 EDT 2017

Function args should go into the block stab.

	Now we get errors if a function body shadows its args.

--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -387,7 +387,7 @@
 		mstart = std.sldup(thr.mstart)
 		mend = std.sldup(thr.mend)
 		hit(re, thr)
-		fork(re, thr, rip, curip, mstart, mend)
+		fork(re, rip, curip, mstart, mend)
 		if re.debug
 			std.slpush(&re.traces, std.bsdup(re.traces[thr.tid]))
 		;;
@@ -407,7 +407,7 @@
 	-> true
 }
 
-const fork = {re, thr, ip, curip, mstart, mend
+const fork = {re, ip, curip, mstart, mend
 	var thr
 
 	if ip == curip /* loop detection */
--- a/parse/node.c
+++ b/parse/node.c
@@ -186,6 +186,7 @@
 	Node *n;
 	Node *f;
 	size_t i;
+	Stab *st;
 
 	f = mknode(loc, Nfunc);
 	f->func.args = args;
@@ -194,8 +195,9 @@
 	f->func.scope = mkstab(1);
 	f->func.type = mktyfunc(loc, args, nargs, ret);
 
+	st = body->block.scope;
 	for (i = 0; i < nargs; i++)
-		putdcl(f->func.scope, args[i]);
+		putdcl(st, args[i]);
 
 	n = mknode(loc, Nlit);
 	n->lit.littype = Lfunc;