From 236567de8d7706b7a6c529670a1a15f4c8b9f95e Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Tue, 30 Jul 2024 10:52:33 -0700 Subject: [PATCH] aro_translate_c: Emit compile errors instead of panicking for var decls --- lib/compiler/aro_translate_c.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/compiler/aro_translate_c.zig b/lib/compiler/aro_translate_c.zig index 02c7547ce5..2e20918d4b 100644 --- a/lib/compiler/aro_translate_c.zig +++ b/lib/compiler/aro_translate_c.zig @@ -304,7 +304,7 @@ fn transDecl(c: *Context, scope: *Scope, decl: NodeIndex) !void { .threadlocal_extern_var, .threadlocal_static_var, => { - try transVarDecl(c, decl, null); + try transVarDecl(c, decl); }, .static_assert => try warn(c, &c.global_scope.base, 0, "ignoring _Static_assert declaration", .{}), else => unreachable, @@ -566,8 +566,10 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void { return addTopLevelDecl(c, fn_name, proto_node); } -fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void { - @panic("TODO"); +fn transVarDecl(c: *Context, node: NodeIndex) Error!void { + const data = c.tree.nodes.items(.data)[@intFromEnum(node)]; + const name = c.tree.tokSlice(data.decl.name); + return failDecl(c, data.decl.name, name, "unable to translate variable declaration", .{}); } fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void {