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,13 +438,11 @@ 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];
switch (op_token_id) {
.Asterisk => { .Asterisk => {
return ((try resolveTypeOfNodeInternal(store, arena, .{ return ((try resolveTypeOfNodeInternal(store, arena, .{
.node = pop.rhs, .node = ptr_type.rhs,
.handle = deref.handle, .handle = deref.handle,
}, bound_type_params)) orelse return null).instanceTypeVal(); }, bound_type_params)) orelse return null).instanceTypeVal();
}, },
@ -452,7 +450,6 @@ fn resolveDerefType(
else => unreachable, 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) {
.ArrayType => {
try list.append(.{ try list.append(.{
.label = "len", .label = "len",
.kind = .Field, .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);
} }