Qualification rewrites a package's own names wherever they are used and has to stop at a binding. Nothing refuses a renamer that does not: the program builds, runs, and reads the top-level name instead. The package in shadow-pkg.flan binds locals called limit and sink over its own constant and var, and the four numbers separate the two halves — dropping the shadowing check in the expression renamer gives 5, dropping it in the place renamer moves the 20 onto the package's sink.
18 lines
685 B
Plaintext
18 lines
685 B
Plaintext
;;;; A local shadowing an imported name (test/programs/shadow-pkg.flan).
|
|
;;;;
|
|
;;;; Nothing about this program is unusual; the package it imports is where the
|
|
;;;; shadowing is. What is asserted is that qualification stopped at the local:
|
|
;;;; 7 rather than the constant's 5, and 20 out of [assigned] with the
|
|
;;;; package's own [sink] still zero. A renamer that qualifies through a
|
|
;;;; binding produces no error anywhere — it silently reads and writes the
|
|
;;;; top-level name instead.
|
|
|
|
(import shd "shadow-pkg.flan")
|
|
|
|
(defn main [] i32
|
|
(print (shd/shadowed)) (println "")
|
|
(print (shd/assigned)) (println "")
|
|
(print shd/sink) (println "")
|
|
(print shd/limit) (println "")
|
|
0)
|