From f2ba3dfc996bfcd67a723b23754e808276ab3b9f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 12 Oct 2021 00:42:16 -0700 Subject: printer: bug: fallback syms printed without prefix. This is a basic read/print consistency problem. When a symbol is printed that is anywhere in the fallback list of the current package, we are dumping it unqualified, even if it is hidden by a same-named symbol in the current package itself or such a symbol occurring earlier in the fallback list. * lib.c (symbol_needs_prefix): When the to-be-printed symbol is found in the fallback list, re-scan the current package for a symbol having the same name, as well as the preceding nodes in the fallback list. If such a symbol is found, then the to-be printed symbol must be package-qualified. * tests/012/syms.expected: New file. * tests/012/syms.tl: Likewise. * tests/012/compile.tl: Pull syms into compile job. * txr.1: Clarify text about this. The existing text's only reasonable interpretation supports the behavior which this patch ensures (which is needed on grounds of read/print consistency) but the text lacks precision. --- tests/012/syms.tl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/012/syms.tl (limited to 'tests/012/syms.tl') diff --git a/tests/012/syms.tl b/tests/012/syms.tl new file mode 100644 index 00000000..007125e2 --- /dev/null +++ b/tests/012/syms.tl @@ -0,0 +1,28 @@ +(load "../common") + +(defpackage fb-2 + (:local loc-0 loc-1 loc-2) + (:fallback usr)) + +(defpackage fb-1 + (:local loc-0 loc-1) + (:fallback fb-2 usr)) + +(defpackage main + (:local loc-0) + (:fallback fb-1 fb-2 usr)) + +(in-package fb-2) + +(prinl '(loc-0 loc-1 loc-2 cons)) + +(in-package fb-1) + +(prinl '(loc-0 loc-1 loc-2 cons)) +(prinl '(fb-2:loc-0 fb-2:loc-1 fb-2:loc-2 fb-2:cons)) + +(in-package main) + +(prinl '(loc-0 loc-1 loc-2 cons)) +(prinl '(fb-2:loc-0 fb-2:loc-1 fb-2:loc-2 fb-2:cons)) +(prinl '(fb-1:loc-0 fb-1:loc-1 fb-1:loc-2 fb-1:cons)) -- cgit v1.2.3