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 @@...@@ -1,5 +1,7 @@
1## 0.1.61## 0.1.6
22
3- fix: crash when printing unused struct declaration error
4
3## 0.1.55## 0.1.5
46
5- feat: clarify "defined runtime representation" and "can be represented at runtime"7- 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 {...@@ -717,6 +717,7 @@ pub fn idToken(ast: Ast, node: NodeIndex) TokenIndex {
717 => ast.nodeToken(node),717 => ast.nodeToken(node),
718 .fn_decl,718 .fn_decl,
719 .var_decl,719 .var_decl,
720 .struct_decl,
720 => ast.nodeToken(node) + 1,721 => ast.nodeToken(node) + 1,
721 else => unreachable, // does not have an id722 else => unreachable, // does not have an id
722 };723 };
src/core/Report.zig+2-1
...@@ -436,6 +436,7 @@ pub const Warn = union(enum) {...@@ -436,6 +436,7 @@ pub const Warn = union(enum) {
436 .param_decl => ctx.ast.fullParamDecl(data.node).id,436 .param_decl => ctx.ast.fullParamDecl(data.node).id,
437 .fn_decl => ctx.ast.fullFnDecl(data.node).id,437 .fn_decl => ctx.ast.fullFnDecl(data.node).id,
438 .var_decl => ctx.ast.fullVarDecl(data.node).id,438 .var_decl => ctx.ast.fullVarDecl(data.node).id,
439 .struct_decl => ctx.ast.fullStructDecl(data.node).id,
439 else => unreachable, // not a valid symbol node440 else => unreachable, // not a valid symbol node
440 };441 };
441442
...@@ -538,7 +539,7 @@ pub const UnusedKind = enum {...@@ -538,7 +539,7 @@ pub const UnusedKind = enum {
538 param,539 param,
539 constant,540 constant,
540 variable,541 variable,
541 function,542 declaration,
542};543};
543544
544pub const String = struct {545pub const String = struct {
src/core/Transform.zig+2-2
...@@ -271,7 +271,7 @@ const Scope = struct {...@@ -271,7 +271,7 @@ const Scope = struct {
271 try t.report.warn(.unused, .{271 try t.report.warn(.unused, .{
272 .node = symbol.node,272 .node = symbol.node,
273 .kind = switch (symbol.data) {273 .kind = switch (symbol.data) {
274 .declaration => .function,274 .declaration => .declaration,
275 .param => .param,275 .param => .param,
276 .mutable => .variable,276 .mutable => .variable,
277 .immutable => switch (t.ast.nodeTag(symbol.node)) {277 .immutable => switch (t.ast.nodeTag(symbol.node)) {
...@@ -1484,7 +1484,7 @@ fn transformAssignmentTarget(...@@ -1484,7 +1484,7 @@ fn transformAssignmentTarget(
1484 .decl = lookup.node,1484 .decl = lookup.node,
1485 .kind = switch (lookup.data) {1485 .kind = switch (lookup.data) {
1486 .mutable => unreachable,1486 .mutable => unreachable,
1487 .declaration => .function,1487 .declaration => .declaration,
1488 .param => .param,1488 .param => .param,
1489 .immutable => switch (t.ast.nodeTag(lookup.node)) {1489 .immutable => switch (t.ast.nodeTag(lookup.node)) {
1490 .param_decl => .param,1490 .param_decl => .param,