Fix various bugs

This commit is contained in:
Alexandros Naskos 2020-07-23 20:30:03 +03:00
parent b71585da1d
commit 213366f029
2 changed files with 17 additions and 25 deletions

View File

@ -438,19 +438,16 @@ fn resolveDerefType(
else => return null, else => return null,
}; };
if (deref_node.cast(ast.Node.SimplePrefixOp)) |pop| { if (deref_node.castTag(.PtrType)) |ptr_type| {
if (deref_node.tag == .PtrType) { switch (deref.handle.tree.token_ids[ptr_type.op_token]) {
const op_token_id = deref.handle.tree.token_ids[pop.op_token]; .Asterisk => {
switch (op_token_id) { return ((try resolveTypeOfNodeInternal(store, arena, .{
.Asterisk => { .node = ptr_type.rhs,
return ((try resolveTypeOfNodeInternal(store, arena, .{ .handle = deref.handle,
.node = pop.rhs, }, bound_type_params)) orelse return null).instanceTypeVal();
.handle = deref.handle, },
}, bound_type_params)) orelse return null).instanceTypeVal(); .LBracket, .AsteriskAsterisk => return null,
}, else => unreachable,
.LBracket, .AsteriskAsterisk => return null,
else => unreachable,
}
} }
} }
return null; return null;
@ -824,7 +821,7 @@ pub fn resolveTypeOfNodeInternal(
}, },
.FnProto => { .FnProto => {
// This is a function type // This is a function type
if (node.castTag(.FnProto).?.trailer_flags.has("name_token")) { if (!node.castTag(.FnProto).?.trailer_flags.has("name_token")) {
return TypeWithHandle.typeVal(node_handle); return TypeWithHandle.typeVal(node_handle);
} }
return TypeWithHandle{ return TypeWithHandle{
@ -1010,7 +1007,7 @@ pub fn getFieldAccessType(
tokenizer: *std.zig.Tokenizer, tokenizer: *std.zig.Tokenizer,
) !?FieldAccessReturn { ) !?FieldAccessReturn {
var current_type = TypeWithHandle.typeVal(.{ var current_type = TypeWithHandle.typeVal(.{
.node = &handle.tree.root_node.base, .node = undefined,
.handle = handle, .handle = handle,
}); });

View File

@ -428,16 +428,11 @@ fn nodeToCompletion(
} }
const ptr_type = node.castTag(.PtrType).?; const ptr_type = node.castTag(.PtrType).?;
if (ptr_type.rhs.cast(std.zig.ast.Node.SimplePrefixOp)) |child_pop| { if (ptr_type.rhs.castTag(.ArrayType) != null) {
switch (ptr_type.rhs.tag) { try list.append(.{
.ArrayType => { .label = "len",
try list.append(.{ .kind = .Field,
.label = "len", });
.kind = .Field,
});
},
else => {},
}
} else if (unwrapped) |actual_type| { } else if (unwrapped) |actual_type| {
try typeToCompletion(arena, list, .{ .original = actual_type }, orig_handle, config); try typeToCompletion(arena, list, .{ .original = actual_type }, orig_handle, config);
} }