The author's rule: "allow shadowing but warn". A user (defn get ...) is legal, the user's definition wins at every call site in the file that wrote it, and the compiler warns once at the definition. Builtin-wins was never a rule anybody wrote: named_call is one match on the name, the builtin arms are string literals, and the three arms that look a name up are the last three in it. So a guard goes first, the trailing three are factored into ordinary_call, and both routes into it resolve a name the same way. The shadow stops at the file that declared it. An imported package's names were qualified at the import, so a get written inside one is the builtin's and stays the builtin's; the prelude is excluded by its file for the same reason. programs/shadow-builtin.flan is both halves at once. The warning prints from build_program, which is what every command and the dev daemon's reload go through, in the shape --warn-memory established: file:line:col, the squiggle, and an exit status that does not move. And the message that described the old world is gone — the builtin-arity note said a defn does not replace a builtin, which is no longer true and is no longer reachable.
11 lines
479 B
Plaintext
11 lines
479 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))
|