Skip to content

fix(emit): replace silent emission failures with structured diagnostics - #10

Merged
odvcencio merged 1 commit into
mainfrom
feat/emission-diagnostics
Jul 27, 2026
Merged

fix(emit): replace silent emission failures with structured diagnostics#10
odvcencio merged 1 commit into
mainfrom
feat/emission-diagnostics

Conversation

@odvcencio

Copy link
Copy Markdown
Contributor

Summary

Converts backend emission failures from silent placeholders and unrecovered panics into structured ir.EmitError diagnostics. Wraps all backend Emit functions with a recovery mechanism to surface these as normal Go errors, and ensures they are correctly mapped to CompileError with SEL codes, messages, and hints.

Changes

  • Introduce ir.EmitError and emission codes (SEL4001, SEL4002, SEL4003) for unknown IR expressions, statements, and unwired resolver nodes.
  • Replace silent fallbacks in ir.Print and emit/internal Resolver methods with panicked *EmitError instances to fail loudly on missing rendering paths.
  • Add internal.Recover and internal.RecoverSplit to convert panicked emission errors into standard error returns in all backend Emit functions.
  • Update diagnostics.go to wrap *EmitError into CompileError and add hints for SEL1006 and SEL4001-4003.
  • Fix lower/lower_helpers.go to report interface name collisions as structured diagnostics instead of unwrapped fmt.Errorf.
  • Update tests across compile, diagnostics, ir, emit/internal, and backend packages to validate new error paths.

Testing

  • run go test ./... to verify new emission error paths and structured diagnostic mapping

- Replace ir.Print's silent "/* unknown expr */" fallback, emit/internal's zero-value Resolver guards, and emitStmt's missing default case with structured panics (SEL4001–SEL4003) that prevent compiles reporting success while emitting wrong or empty shaders
- Add internal.Recover and RecoverSplit wrappers around each backend Emit entry point so panicked *ir.EmitError values surface as normal Go error returns instead of crashing the process
- Wire ir.EmitError into diagnostics.go compileError so emission failures get the same Code/Message/Hint shape as parse and lower diagnostics, with hints for the SEL4001–SEL4003 bug-report codes
- Promote lower/interfaceNames collision from a bare fmt.Errorf to a structured SEL1006 diagnostic so compileError can wrap it into *CompileError for end-to-end error reporting
@odvcencio
odvcencio merged commit 43006b5 into main Jul 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant