Skip to content

ns.name is the namespace's member or an error - #580

Merged
ASDAlexander77 merged 2 commits into
mainfrom
ns-missing-member-error
Oct 17, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
ns-missing-member-error

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

#569 looked a qualified name up in the namespace first, then fell back to the general lookup. That lookup searched the calling function's locals and the outer namespaces too, so these compiled and used the wrong thing:

namespace ns { export function value(): int { return 42; } }
function outer(): int { return 1; }
function main() {
    const missing = 5;
    print(ns.missing);   // printed 5, now: error: Can't resolve property 'missing' of type ns
    print(ns.outer());   // printed 1, now: error: Can't resolve property 'outer' of type ns
}
  • The namespace case of a property access now takes only what resolveIdentifierInNamespace finds; a miss goes on to the usual "Can't resolve property" error (partial-resolve runs keep their non-fatal path).
  • import * as M makes M an empty namespace whose names are declared at the top level; the fallback was how M.add found them. Such a namespace is now marked isModuleImport, and its access looks in the root namespace, still never in locals.

Tests:

  • namespace-member/missing_member.ts, namespace-member/outer_member.ts: error text and position.
  • 00ns_member_shadowed.ts: a member used before its declaration, and one from a second namespace ns2 {} block.
  • import-bindings/import_namespace.ts: M.ANSWER with a local ANSWER in scope.

Full Release suite: 4091/4091 passed. The first run without the import * as M handling failed only the three import-bindings-namespace tests.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits October 17, 2026 12:21
#569 looked the name up in the namespace first, then fell back to the
general lookup, which searched the calling function's locals and the
outer namespaces: `ns.missing` with a local `missing` in scope, or
`ns.outer()` with a root-level `outer`, compiled and used those. The
access now takes only what the namespace has; a name it hasn't got is
"Can't resolve property 'missing' of type ns".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
M is a namespace with nothing in it, whose names are declared at the top
level; the fallback the previous commit removed was how they were found.
Such a namespace is marked, and its access looks in the root namespace,
still not in the calling function's locals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit e376f18 into main Oct 17, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the ns-missing-member-error branch October 17, 2026 13:00
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