namespace GolangLean /-- Runtime / static errors produced anywhere in the Go toolchain. -/ inductive GoError where | scan (msg : String) (line col : Nat) -- lexical | parse (msg : String) (line col : Nat) -- syntactic | typeErr (msg : String) -- static type-check | runtime (msg : String) -- panic / runtime | nilDeref -- nil-pointer dereference | indexOOB (i n : Int) -- index out of range | divByZero | notImpl (what : String) -- placeholder for stubs deriving Repr, Inhabited def GoError.toString : GoError → String | .scan m l c => s!"scan error: {m} ({l}:{c})" | .parse m l c => s!"parse error: {m} ({l}:{c})" | .typeErr m => s!"type error: {m}" | .runtime m => s!"runtime error: {m}" | .nilDeref => "runtime error: nil pointer dereference" | .indexOOB i n => s!"runtime error: index out of range [{i}] with length {n}" | .divByZero => "runtime error: integer divide by zero" | .notImpl what => s!"not implemented: {what}" instance : ToString GoError := ⟨GoError.toString⟩ end GolangLean