Skip to content

Support aliased imports for external packages #318

@heartwilltell

Description

@heartwilltell

Phase 5: Compiler Integration — RFC #218

Implement aliased imports (use mux "github.com/user/router") so users can rename packages on import. The alias becomes the local symbol name instead of the last path segment.

Closes #221.

Example

use mux "github.com/user/router"    // use as: mux.Handle(...)
use "github.com/user/repo/auth"     // use as: auth.Verify(...)

Acceptance Criteria

  • Parser accepts use <ident> <string> syntax
  • Alias identifier becomes the package symbol name
  • Original path is still used for resolution
  • Non-aliased imports continue to work unchanged
  • Error if alias conflicts with another import name
  • Tests for aliased and non-aliased imports

Files

  • Modified: src/parser.zig (new import syntax)
  • Modified: src/ast.zig (potentially new node variant)
  • Modified: src/resolve.zig

Dependencies

Independent of multi-file compilation (#314-316).

Part of the Package Manager RFC.

Metadata

Metadata

Assignees

Labels

compilerCompiler internals (IR, codegen, optimizer)enhancementNew feature or requestpackage-managerPackage manager (run.toml, dependencies, resolution)

Type

No fields configured for Task.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions