Skip to content

Source: Implement FileId and Source struct #4

@pdaxt

Description

@pdaxt

Component

Foundation / Source

Task

Implement FileId and Source structs for source file management.

Acceptance Criteria

  • FileId newtype wrapper (u32)
  • Source struct with: id: FileId, name: String, content: String
  • Source::new(name, content) -> Source
  • Source::slice(span) -> &str
  • Line offset cache for efficient lookups

Verify

let src = Source::new("test.nova", "let x = 42");
assert_eq!(src.slice(Span::new(4, 5)), "x");

Security Testing (REQUIRED)

  • Test with empty source files
  • Test with very large files (>4GB would overflow u32)
  • Test Unicode edge cases (multi-byte chars, emoji)
  • Test invalid Span ranges (out of bounds)
  • Verify no panics on malformed input

Ref: FOUNDATION.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    foundationFoundation tier componentssourceSource component

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions