Bug stream fixes (#818)

* Fix glaring inlay hint issue; thanks for the report Nameless

* Fix label references; closes #728
This commit is contained in:
Auguste Rame
2022-12-13 22:07:36 -05:00
committed by GitHub
parent 5dca821eb6
commit 0ab34abc0f
4 changed files with 39 additions and 27 deletions

View File

@@ -243,16 +243,16 @@ fn writeCallNodeHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
/// HACK self-hosted has not implemented async yet
fn callWriteNodeInlayHint(allocator: std.mem.Allocator, args: anytype) error{OutOfMemory}!void {
if (zig_builtin.zig_backend == .other or zig_builtin.zig_backend == .stage1) {
const FrameSize = @sizeOf(@Frame(writeNodeInlayHint));
var child_frame = try allocator.alignedAlloc(u8, std.Target.stack_align, FrameSize);
defer allocator.free(child_frame);
return await @asyncCall(child_frame, {}, writeNodeInlayHint, args);
} else {
// TODO find a non recursive solution
return @call(.{}, writeNodeInlayHint, args);
}
_ = allocator;
// if (zig_builtin.zig_backend == .other or zig_builtin.zig_backend == .stage1) {
// const FrameSize = @sizeOf(@Frame(writeNodeInlayHint));
// var child_frame = try allocator.alignedAlloc(u8, std.Target.stack_align, FrameSize);
// defer allocator.free(child_frame);
// return await @asyncCall(child_frame, {}, writeNodeInlayHint, args);
// } else {
// TODO find a non recursive solution
return @call(.{}, writeNodeInlayHint, args);
// }
}
/// iterates over the ast and writes parameter hints into `builder.hints` for every function call and builtin call
@@ -266,7 +266,11 @@ fn writeNodeInlayHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
const node_data = tree.nodes.items(.data);
const main_tokens = tree.nodes.items(.main_token);
if (node == 0 or node > node_data.len) return;
// std.log.info("max: {d} | curr: {d}", .{ node_data.len, node });
// if (node == 0 or node >= node_data.len) return;
if (node == 0) return;
// std.log.info("tag: {any}", .{node_tags[node]});
// std.log.info("src: {s}", .{tree.getNodeSource(node)});
var allocator = arena.allocator();
@@ -452,7 +456,6 @@ fn writeNodeInlayHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
.bool_or,
.array_access,
.switch_range,
.error_value,
.error_union,
=> {
try callWriteNodeInlayHint(allocator, .{ builder, arena, store, node_data[node].lhs, range });
@@ -679,6 +682,8 @@ fn writeNodeInlayHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
try callWriteNodeInlayHint(allocator, .{ builder, arena, store, asm_node.ast.template, range });
},
.error_value => {},
}
}