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

View File

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