mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
The script checker kept a replacement of a variable's methods
(`give(local)`, `local.saveAs = w`) for the body that had declared the
name so far in the text. A `var` statement declares the name for the
whole body, and a parameter is the function's own variable, so the
replacement could count for the wrong variable:
- A function whose own later `var local` or parameter `local` declares
the name no longer ends the exemption of an outer `local`'s own
`saveAs` (`function h(a, local) { return local; }`).
- A replacement now counts for the innermost body around it that
declares the name anywhere in the body, found once every body's
names are known.
- When a body past the nesting limit or out of room for its names is
around the replacement, the declaring body is not known, and the
replacement counts for a variable of that name in every body.
- The call site looks the replacement up for the body that declares
the receiver, walking outward from the innermost body.