flan/test/programs/import-builtin-alias.flan
Joseph Ferano 40d62e7643 builtin/name, the spelling a shadow cannot take away
A defn named after a builtin wins for its whole file, and until now that
was the end of it: the builtin had no remaining spelling, so a defn that
meant to wrap one was unbounded recursion. builtin/len is the builtin len
wherever it is written, shadowed or not.

The qualifier is the package one's, and builtin is reserved rather than
resolved: Load refuses it as an import alias, Check refuses it as a
declaration's name, and those two doors are the only ways a qualifier can
be made. named_call and var each strip the prefix and re-enter with a flag
that the shadowing guard consults, so every arm below sees the bare name
and refuses in the builtin's own words.

The shadow warning now names the escape in its second half.
2026-09-20 20:17:17 +07:00

17 lines
744 B
Plaintext

;;;; The reserved qualifier, from the import's side. Refused, never built.
;;;;
;;;; builtin/len means the compiler's len and must go on meaning it, which is
;;;; only true while nothing else can produce the qualifier "builtin". Every
;;;; qualifier in a finished program comes from an import's alias, so refusing
;;;; that one alias is the whole of the reservation — there is no other door.
;;;;
;;;; It is the alias that is reserved and not the directory: the package this
;;;; names is imported under its own alias by shadow-builtin.flan and is fine
;;;; there. The importer chooses the qualifier, so the importer is where the
;;;; collision is.
(import builtin "pkgs/shadowed")
(defn main [] ()
(println (builtin/field {:a 1 :b 4})))