flan/test/programs/pkgs/shadowed/shadowed.flan
Joseph Ferano a983a46ea5 The review's follow-ups: a file decides the shadow, and a set answers the membership
The leak review found: an importer's (defn len ...) reached inside an
imported package's (defvar sz i32 (len "abcd")) and made it 999. A global
initialiser is checked with no enclosing function, so the qualified name the
first cut asked about was not there to ask. The file the definition was
written in is what the shadow follows now, which is what FIX.org had already
named as the fix if it ever mattered. It mattered.

builtin_set beside builtin_names: the guard is the first arm of the dispatch
and ran a linear walk of eighty-odd strings at every named call. The list
stays for the did-you-mean, whose order is its order.

Pinned: a shadowed operator warns and lowers to a Call, and a call carrying
another file's name reaches the builtin. The corpus program grew both cases
and the package grew the initialiser that demonstrated the leak.

And the int/float section's sentence about "the arity precedent, where the
builtin wins" now says that the precedent was deleted the same day, since
this lane is what deleted it.
2026-09-20 19:56:17 +07:00

19 lines
813 B
Plaintext

;;;; A package that calls the builtin get, imported by a program that defines
;;;; a get of its own.
;;;;
;;;; The importer's defn takes the name over in the importer's own file and
;;;; nowhere else: this file's names were qualified at the import (this
;;;; function is shadowed/field to everything downstream), so the get written
;;;; here is the builtin's, was compiled as the builtin's, and answers what a
;;;; dyn map holds under a keyword.
(defn field [m] dyn (get m :b))
;;; The same question asked where there is no enclosing function to be
;;; qualified: a global's initialiser, which runs at startup and is checked
;;; with no owner at all. The importer below defines a len of its own; this
;;; one is the builtin's and this global is 4.
(defvar size i32 (len "abcd"))
(defn stored-size [] i32 size)