Skip to content

Integrate and apply the error crate to Wave's compiler diagnostics #168

Closed

Description

@LunaStev

Background:

Wave includes a Rust-based error crate that defines a detailed error handling system, modeled after Rust's own diagnostic approach.
This system already contains a structured WaveError and WaveErrorKind enum with display logic, supporting error messages, source highlighting, and custom labels.

However, this system is not yet integrated into the compiler or parser pipeline.
Currently, errors are either printed ad-hoc or not standardized, and the error.rs module is left unused.

Goal:

Upgrade and fully integrate the error crate into the Wave compiler so that all parsing, syntax, and semantic errors go through this centralized system.

Example (error.rs):

#[derive(Debug)]
pub enum WaveErrorKind {
    UnexpectedToken(String),
    ExpectedToken(String),
    UnexpectedChar(char),
    SyntaxError(String),
}

#[derive(Debug)]
pub struct WaveError {
    pub kind: WaveErrorKind,
    pub message: String,
    pub file: String,
    pub line: usize,
    pub column: usize,
    pub source: Option<String>,
    pub label: Option<String>,
}

// with_source(), with_label(), display() already implemented.

Expected Behavior:

  • All compiler/parsing errors should be reported using WaveError::display()
  • Errors should show:
    • Message
    • File / line / column
    • Source line (if available)
    • Label (if provided)
  • Makes Wave error reporting more professional and user-friendly

Tasks:

  • Review and refactor existing error messages to use WaveError
  • Replace eprintln!based ad-hoc errors
  • Connect the error crate to parsing, tokenizing, and semantic checks
  • Ensure unit tests display proper diagnostic output
  • Optionally: consider returning Result<T, WaveError> where appropriate

Additional Information:

  • Language version: - (planned feature, not yet in production)

  • Target branch: develop

  • Inspired by Rust's compiler error format

  • This system will serve as the foundation for future improvements like linting, suggestions, and warnings

Activity

  1. self-assigned this
    on May 31, 2025
  2. added
    enhancement
    feature request
    on May 31, 2025
  3. added
    discussion
    on May 31, 2025
  4. moved this to Ready in Waveon Jun 2, 2025
  5. moved this from Ready to Backlog in Waveon Jun 22, 2025
  6. LunaStev commented on Aug 25, 2026

    @LunaStev
    MemberAuthor

    The shared WaveError path is now integrated through the lexer, compiler driver, imports, modules, and semantic diagnostics, including structured source spans and JSON rendering. Remaining legacy parser-side println! paths are tracked with bounded follow-up work in #346 and its child issues #359–#362. Closing this broad integration issue as completed.

  7. moved this from Backlog to Done in Waveon Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionenhancementfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions