Skip to content

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

@LunaStev

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

Metadata

Metadata

Assignees

Labels

discussionIssues that require a technical or community discussion.enhancementA request for a new feature or improvement.feature requestA request for a new feature or functionality.

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions