Skip to content

scope module globals; report one error per unknown method#276

Merged
kacy merged 1 commit into
mainfrom
close-gaps
Jul 8, 2026
Merged

scope module globals; report one error per unknown method#276
kacy merged 1 commit into
mainfrom
close-gaps

Conversation

@kacy

@kacy kacy commented Jul 8, 2026

Copy link
Copy Markdown
Owner

summary

the two remaining filed checker gaps, one PR:

  1. module-scoped globals — the shared global scope let any module's names resolve everywhere (check ok, emission dies with "unknown load source"). every binding now carries its defining module; foreign names error at check time with a fix hint unless from-imported. visibility considers all bindings of a name (a builtin re-registered by std.math must not lose its builtin standing — the sqrt case). first run caught 18 latent violations in the emitter itself (lookup_type_id ×17, ir_result_field_kind), now explicitly imported.
  2. one error per unknown method — tables that report a specific error (Set has no method 'insert' — use add) no longer get a generic "no method" stacked on top; the tail dedupes by position. an attempt to stop dispatch on TID_ERR instead broke seven suites — the fallthrough is load-bearing for generic-body element types — so dispatch semantics are untouched.

what was tested

full suite green (all four golden checks), fixed point byte-identical, seed refreshed, fmt gates clean; set.insert reports exactly one E209; stdlib_import (builtin-shadow case) and bytes_io both pass; the compiler compiles itself under its own new visibility rule.

the two remaining filed checker gaps, closed together.

module visibility: the shared global scope let any module's names
resolve from any other module — checks passed, emission died later
with "unknown load source". every binding now carries the module that
defined it, and an identifier defined only by foreign modules is an
error unless the current module from-imports the name. visibility
asks whether any binding of the name is builtin or local, not which
binding wins the lookup — a builtin like sqrt is re-registered by
std.math, and the later registration must not shadow the builtin's
standing. the first run of the enforcement caught eighteen latent
violations inside the emitter itself: lookup_type_id used seventeen
times and ir_result_field_kind once, all riding the leak. their
imports are now explicit.

double reporting: a method table that recognizes a method and reports
a specific error returned TID_ERR, and the dispatch tail stacked a
generic "no method" on top. the tail now skips its report when an
error already sits at the same position. an earlier attempt stopped
dispatch on TID_ERR instead and broke seven suites — the fallthrough
is load-bearing for element types in generic bodies, so dispatch
semantics stay untouched and only the duplicate report goes.
@kacy kacy merged commit 59d264a into main Jul 8, 2026
2 checks passed
@kacy kacy deleted the close-gaps branch July 8, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant