wavefnd / wavefnd/Wave

Replace LLVM backend panics with a typed code generation error channel

Open
#409 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted technical debt
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

## Problem

The LLVM backend currently uses many `panic!`, `unwrap`, and `expect` calls for unsupported types, missing semantic facts, IR builder failures, target-machine failures, object emission, and external tool execution. The driver catches panics as a last resort, but users receive an internal-error style diagnostic and embedders cannot recover cleanly.

## Scope

- Define a typed backend error carrying phase, operation, optional source identity/span, and underlying LLVM/tool message.
- Make top-level IR/object/assembly emission APIs return `Result`.
- Convert expected user-triggerable failures first: invalid lowering inputs, LLVM builder errors, pass failures, target machine creation, file emission, and linker/tool launch.
- Reserve panic for documented impossible invariants.
- Translate backend errors once in the CLI to human and JSON diagnostics.
- Avoid string-matching panic messages in `src/runner.rs`.

## Completion criteria

- [ ] Public LLVM codegen entry points return `Result`.
- [ ] Representative invalid programs and missing-tool cases do not unwind.
- [ ] Human and JSON diagnostics include the backend phase.
- [ ] No partial output artifact is reported as successful.
- [ ] Tests distinguish a user/codegen error from an internal invariant violation.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the LLVM codegen entry points and the panic handling in src/runner.rs. Identify the emission, lowering, tool-launch, and diagnostic paths named in the issue before changing their interfaces. Done means public codegen returns Result, representative invalid and missing-tool cases do not unwind, diagnostics include the backend phase, and tests distinguish user errors from invariant violations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.