feature. See also
. The project being documented here (as the example) is the Zig library itself.
Translator.failDeclExtra
pub fn failDeclExtra(
t: *Translator,
scope: *Scope,
loc: aro.Source.Location,
name: []const u8,
comptime format: []const u8,
args: anytype,
) Error!void
File
Code
pub fn failDeclExtra(
t: *Translator,
scope: *Scope,
loc: aro.Source.Location,
name: []const u8,
comptime format: []const u8,
args: anytype,
) Error!void {
// pub const name = @compileError(msg);
const fail_msg = try std.fmt.allocPrint(t.arena, format, args);
const fail_decl = try ZigTag.fail_decl.create(t.arena, .{
.actual = name,
.mangled = fail_msg,
.local = scope.id != .root,
});
const str = try t.locStr(loc);
const location_comment = try std.fmt.allocPrint(t.arena, "// {s}", .{str});
const loc_node = try ZigTag.warning.create(t.arena, location_comment);
if (scope.id == .root) {
try t.addTopLevelDecl(name, fail_decl);
try scope.appendNode(loc_node);
} else {
try scope.appendNode(fail_decl);
try scope.appendNode(loc_node);
const bs = try scope.findBlockScope(t);
try bs.discardVariable(name);
}
}