Skip to content

Commit

Permalink
add a safe getIdent because that's probably useful
Browse files Browse the repository at this point in the history
you know for when you're handling another error and don't want to panic
in the middle of trying to print debug info
I might've done this. might've. Definitely didn't. Just might've in the
future. Trust me
  • Loading branch information
probably-neb committed May 10, 2024
1 parent 01bf2fd commit 49a1621
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ir/ir.zig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ pub fn astTypeToIRType(self: *IR, astType: Ast.Type) Type {
};
}

pub fn safeGetIdent(self: *const IR, id: StrID) ![]const u8 {
// this is only supposed to be used for debugging, so just panic
return self.intern_pool.get(id);
}

pub fn getIdent(self: *const IR, id: StrID) []const u8 {
// this is only supposed to be used for debugging, so just panic
return self.intern_pool.get(id) catch unreachable;
Expand Down

0 comments on commit 49a1621

Please sign in to comment.