diff --git a/CHANGELOG.md b/CHANGELOG.md index b554fd0270044055b07572dc477acd4bafe700f2..187b88bd7f4648e6784679b41e318bb9f3577b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.1.6 +- fix: crash when printing unused struct declaration error + ## 0.1.5 - feat: clarify "defined runtime representation" and "can be represented at runtime" diff --git a/src/core/Ast.zig b/src/core/Ast.zig index 788346e7ec2f57c55194232e3a3d420e0127313a..b4434183b72c4755c28a6e08f5a36daf41e43dec 100644 --- a/src/core/Ast.zig +++ b/src/core/Ast.zig @@ -717,6 +717,7 @@ pub fn idToken(ast: Ast, node: NodeIndex) TokenIndex { => ast.nodeToken(node), .fn_decl, .var_decl, + .struct_decl, => ast.nodeToken(node) + 1, else => unreachable, // does not have an id }; diff --git a/src/core/Report.zig b/src/core/Report.zig index 18fc277abcce5dd1e39f0ea8cf9aab2f7a264ff5..69689da1a87eb35acc66c70dcfe8b902faf15ab9 100644 --- a/src/core/Report.zig +++ b/src/core/Report.zig @@ -436,6 +436,7 @@ pub const Warn = union(enum) { .param_decl => ctx.ast.fullParamDecl(data.node).id, .fn_decl => ctx.ast.fullFnDecl(data.node).id, .var_decl => ctx.ast.fullVarDecl(data.node).id, + .struct_decl => ctx.ast.fullStructDecl(data.node).id, else => unreachable, // not a valid symbol node }; @@ -538,7 +539,7 @@ pub const UnusedKind = enum { param, constant, variable, - function, + declaration, }; pub const String = struct { diff --git a/src/core/Transform.zig b/src/core/Transform.zig index 0c2a57a99f641bf0d020b2fb6ad6304492193372..64e88f321ae0557681f065b77c091f2eba72d152 100644 --- a/src/core/Transform.zig +++ b/src/core/Transform.zig @@ -271,7 +271,7 @@ const Scope = struct { try t.report.warn(.unused, .{ .node = symbol.node, .kind = switch (symbol.data) { - .declaration => .function, + .declaration => .declaration, .param => .param, .mutable => .variable, .immutable => switch (t.ast.nodeTag(symbol.node)) { @@ -1484,7 +1484,7 @@ fn transformAssignmentTarget( .decl = lookup.node, .kind = switch (lookup.data) { .mutable => unreachable, - .declaration => .function, + .declaration => .declaration, .param => .param, .immutable => switch (t.ast.nodeTag(lookup.node)) { .param_decl => .param,