Skip to content

Unified: Add static name binding pass - #22299

Draft
asgerf wants to merge 24 commits into
github:mainfrom
asgerf:unified/static-name-binding
Draft

Unified: Add static name binding pass#22299
asgerf wants to merge 24 commits into
github:mainfrom
asgerf:unified/static-name-binding

Conversation

@asgerf

@asgerf asgerf commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

asgerf added 24 commits August 7, 2026 10:58
getValue() returns an empty string for various literals
This supports only a minimal set of features but sets up the structure
we'll be using for supporting more features.
The restriction to classes was more permanent that anticipated, since
top-level scopes instead target a TModuleScope
Scoped imports like 'import class B.C' are mapped to an AST of form

ImportDeclartion
  pattern: NamePattern "C"
  importedExpr:  MemberAccessExpr
    base: "B"
    member: "C"

The NamePattern introduces a local alias for 'C', but unlike type aliases we also resolve to the ultimate target, when it's coming through an import.
Program was not valid unless these were public
Module names can only be referenced by an import declaration, they cannot appear directly on front of a type name unless the module is also imported.
An `import X` declaration now does two things:
- X becomes a local name binding
- X is bulk-imported into the local scope

The AST mapping now maps it to X with a bulk-importing pattern as a sub-pattern.

Module names can no longer be referenced anywhere except as the leading qualifier of an import statement.
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Aug 7, 2026
private import codeql.util.Unit
private import codeql.unified.internal.NameBindingPluginSwift // ensure overrides are seen

/** Extension point for language-specific inputs to name binding. */
Comment on lines +39 to +44
/**
* Representative for a module scope.
*
* Module scopes can encompass a set of files, and is the canonical representative
* for the top-level members collectively exported from those files.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants