ref: 1af62a6b4e9e10444098c57f64b1ad1b9cb03b95
parent: 3df8885d396e1bc36fe25a329bc4e63400126ecf
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Nov 28 07:00:09 EST 2017
Allow local variables to shadow namespaces. It means you can't access the namespace in that scope, but it also means that we don't get the weird behavior that the undotted name refers to the variable, but the dotted name refers to the namespace. Fixes #158
--- a/lib/regex/test/testmatch.myr
+++ b/lib/regex/test/testmatch.myr
@@ -65,10 +65,10 @@
run(regex.dbgcompile(pat, true), pat, text, expected, false)
}
-const subst = {regex, pat, text, sub, expected, all
+const subst = {restr, pat, text, sub, expected, all
var re, r
- re = std.try(regex)
+ re = std.try(restr)
if all
r = `std.Some regex.suball(re, text, sub)
else
@@ -94,11 +94,11 @@
;;
}
-const runidx = {regex, pat, text, expected : std.option((std.size, std.size)[:]), search
+const runidx = {restr, pat, text, expected : std.option((std.size, std.size)[:]), search
var re, r
var lo, elo, hi, ehi
- re = std.try(regex)
+ re = std.try(restr)
if search
r = regex.isearch(re, text)
else
@@ -139,10 +139,10 @@
;;
regex.free(re)
}
-const run = {regex, pat, text, expected, search
+const run = {restr, pat, text, expected, search
var i, re, r
- re = std.try(regex)
+ re = std.try(restr)
if search
r = regex.search(re, text)
else
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1398,7 +1398,7 @@
return n;
name = args[0]->expr.args[0];
stab = getns(namestr(name));
- if (!stab)
+ if (!stab || getdcl(curstab(), name))
return n;
/* substitute the namespaced name */