diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-29 14:17:18 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-29 14:17:18 -0800 |
commit | b75f188c4991ac07ce7d6db8caaccda8ed4e1542 (patch) | |
tree | a75688b487e1a4f0d0cf454e54c1153773d16d6a /lib.c | |
parent | 3dc7aa2ef572a26f9c5e0ea134b43c80a013e8f5 (diff) | |
download | txr-b75f188c4991ac07ce7d6db8caaccda8ed4e1542.tar.gz txr-b75f188c4991ac07ce7d6db8caaccda8ed4e1542.tar.bz2 txr-b75f188c4991ac07ce7d6db8caaccda8ed4e1542.zip |
bugfix: read print consistency of shadowed symbols.
Suppose that a program-defined package is current, has usr as
its :fallback, and has a :local symbol list. Then if 'usr:list
is printed, it must print with the usr: package symbol because
it is not visible. It is printing without the prefix.
* lib.c (symbol_present): Function renamed to symbol_visible,
which is much more descriptive of what its return value means.
The bug in this function is that it does not stop searching
when, in its search path, it encounters a symbol which has the
same name as sym, but which isn't sym. But such a symbol makes
sym invisible. This is now fixed.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -5021,23 +5021,30 @@ val unuse_package(val unuse_list, val package_in) return unuse_package_list; } -static val symbol_present(val package, val sym) +static val symbol_visible(val package, val sym) { + val name = symbol_name(sym); type_check (package, PKG); if (sym->s.package == package) return t; - if (gethash(package->pk.symhash, symbol_name(sym)) == sym) - return t; + { + val cell = gethash_e(package->pk.symhash, name); + + if (cell) + return eq(car(cell), sym); + } { val fallback = get_hash_userdata(package->pk.symhash); for (; fallback; fallback = cdr(fallback)) { val fb_pkg = car(fallback); - if (gethash(fb_pkg->pk.symhash, symbol_name(sym)) == sym) - return t; + val cell = gethash_e(fb_pkg->pk.symhash, name); + + if (cell) + return eq(car(cell), sym); } } @@ -9659,7 +9666,7 @@ static int unquote_star_check(val obj, val pretty) return 0; if (car(obj->s.name) != chr('*')) return 0; - return pretty || symbol_present(cur_package, obj); + return pretty || symbol_visible(cur_package, obj); } val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) @@ -9914,7 +9921,7 @@ dot: put_string(lit("#:"), out); } else if (obj->s.package == keyword_package) { put_char(chr(':'), out); - } else if (!symbol_present(cur_package, obj)) { + } else if (!symbol_visible(cur_package, obj)) { put_string(obj->s.package->pk.name, out); put_char(chr(':'), out); } |