From 7bc150f6d87b836b7690f8d73ee815ea8c718b13 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 3 Apr 2018 20:36:23 -0700 Subject: packages: fix package prefix read/print issue. Suppose that we have two symbols of the same name, in two packages: foo:sym and bar:sym. Suppose that the bar package has foo in its package fallback list, and suppose bar is the current package. Then bar:sym prints without a package prefix, as just sym. However, this is potentially ambiguous. Suppose that bar:sym is written to a file as just sym. Then later the file is read into a fresh image in a situation in which bar:sym has not yet been interned, but foo:sym already exists. In this situation, sym will just resolve to foo:sym. The printer must detect this ambiguous situation. If a symbol is present in a package, but a same-named symbol is in the fallback list; or if a symbol is visible in the fallback list, but a same-named symbol is present in the package, then a package prefix should be printed. * lib.c (symbol_needs_prefix): New function. (unquote_star_check, obj_print_impl): Use symbol_needs_prefix rather than symbol_visible. * lib.h (symbol_needs_prefix): Declared. --- lib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib.h') diff --git a/lib.h b/lib.h index f39f075a..6fe29fe2 100644 --- a/lib.h +++ b/lib.h @@ -843,6 +843,7 @@ val unuse_sym(val symbol, val package); val use_package(val use_list, val package); val unuse_package(val unuse_list, val package); val symbol_visible(val package, val sym); +val symbol_needs_prefix(val package, val sym); val find_symbol(val str, val package); val intern(val str, val package); val unintern(val sym, val package); -- cgit v1.2.3