authorchloe caruso <git@paperclover.net> 2024-07-27 05:40:51-07:00
committerchloe caruso <git@paperclover.net> 2024-07-27 05:40:51-07:00
log5cf49e3076b8b164365110993b153e7d4e9989ae
tree14d15df9c4c6841b24ae2f9001e78c1b051afe7e
parentfa1203bfb6f9c868b0186ef5c81defc7f871d901

fix: crash when printing unused struct declaration error


4 files changed, 7 insertions(+), 3 deletions(-)

CHANGELOG.md+2
......@@ -1,5 +1,7 @@
11## 0.1.6
22
3- fix: crash when printing unused struct declaration error
4
35## 0.1.5
46
57- feat: clarify "defined runtime representation" and "can be represented at runtime"
src/core/Ast.zig+1
......@@ -717,6 +717,7 @@ pub fn idToken(ast: Ast, node: NodeIndex) TokenIndex {
717717 => ast.nodeToken(node),
718718 .fn_decl,
719719 .var_decl,
720 .struct_decl,
720721 => ast.nodeToken(node) + 1,
721722 else => unreachable, // does not have an id
722723 };
src/core/Report.zig+2-1
......@@ -436,6 +436,7 @@ pub const Warn = union(enum) {
436436 .param_decl => ctx.ast.fullParamDecl(data.node).id,
437437 .fn_decl => ctx.ast.fullFnDecl(data.node).id,
438438 .var_decl => ctx.ast.fullVarDecl(data.node).id,
439 .struct_decl => ctx.ast.fullStructDecl(data.node).id,
439440 else => unreachable, // not a valid symbol node
440441 };
441442
......@@ -538,7 +539,7 @@ pub const UnusedKind = enum {
538539 param,
539540 constant,
540541 variable,
541 function,
542 declaration,
542543};
543544
544545pub const String = struct {
src/core/Transform.zig+2-2
......@@ -271,7 +271,7 @@ const Scope = struct {
271271 try t.report.warn(.unused, .{
272272 .node = symbol.node,
273273 .kind = switch (symbol.data) {
274 .declaration => .function,
274 .declaration => .declaration,
275275 .param => .param,
276276 .mutable => .variable,
277277 .immutable => switch (t.ast.nodeTag(symbol.node)) {
......@@ -1484,7 +1484,7 @@ fn transformAssignmentTarget(
14841484 .decl = lookup.node,
14851485 .kind = switch (lookup.data) {
14861486 .mutable => unreachable,
1487 .declaration => .function,
1487 .declaration => .declaration,
14881488 .param => .param,
14891489 .immutable => switch (t.ast.nodeTag(lookup.node)) {
14901490 .param_decl => .param,