Skip to content

Commit

Permalink
Parser: return an error string if rendering invalid types in release …
Browse files Browse the repository at this point in the history
…modes
  • Loading branch information
ehaas committed Dec 15, 2023
1 parent e498fdb commit 3f95310
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ pub fn removeNull(p: *Parser, str: Value) !Value {
}

pub fn typeStr(p: *Parser, ty: Type) ![]const u8 {
if (@import("builtin").mode != .Debug) {
if (ty.is(.invalid)) {
return "Tried to render invalid type - this is an aro bug.";
}
}
if (Type.Builder.fromType(ty).str(p.comp.langopts)) |str| return str;
const strings_top = p.strings.items.len;
defer p.strings.items.len = strings_top;
Expand All @@ -446,6 +451,11 @@ pub fn typePairStr(p: *Parser, a: Type, b: Type) ![]const u8 {
}

pub fn typePairStrExtra(p: *Parser, a: Type, msg: []const u8, b: Type) ![]const u8 {
if (@import("builtin").mode != .Debug) {
if (a.is(.invalid) or b.is(.invalid)) {
return "Tried to render invalid type - this is an aro bug.";
}
}
const strings_top = p.strings.items.len;
defer p.strings.items.len = strings_top;

Expand Down

0 comments on commit 3f95310

Please sign in to comment.