Skip to content

Module Resolution & Hierarchical Loading #113

@rz1989s

Description

@rz1989s

Description

Implement the ModuleResolver to handle hierarchical module loading with mod name; declarations.

This is part of the nested module system implementation (#53), broken down into manageable sub-issues.

Tasks

  • Create module_resolver.rs with ModuleResolver struct
  • Implement resolve_module_declaration() for mod foo;foo.lumos or foo/mod.lumos
  • Add module tree construction (parent-child relationships)
  • Implement path resolution for crate::, super::, self::
  • Add circular module dependency detection
  • Update FileResolver to use ModuleResolver
  • Add module resolution tests (10+ test cases)

Acceptance Criteria

  • mod models; correctly resolves to models.lumos or models/mod.lumos
  • Module tree structure tracks parent-child relationships
  • crate::models::User resolves from any module
  • super::types::UserId resolves relative to parent
  • Circular module dependencies detected with clear error
  • All existing tests pass + 10 new module resolution tests

Technical Details

Resolution Algorithm:
For mod foo; in file path/to/file.lumos:

  1. Check path/to/foo.lumos (sibling file)
  2. If not found, check path/to/foo/mod.lumos (directory module)
  3. If neither exists, error: module not found

Path Resolution:

  • crate:: - Absolute from root
  • super:: - Parent module
  • self:: - Current module
  • module:: - Relative child

Estimated Time

4-6 hours

Dependencies

Priority

High - Core functionality needed for module system

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreCore compiler (parser, generator, IR, transform)high-priorityHigh priority tasktype:featureNew feature or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions