Resovle parens, only skip empty container fields where we have to

This commit is contained in:
Alexandros Naskos 2020-06-11 11:12:31 +03:00
parent 28e9d08f03
commit 693e810d75

View File

@ -381,6 +381,10 @@ pub fn resolveTypeOfNode(store: *DocumentStore, arena: *std.heap.ArenaAllocator,
}
return decl;
},
.GroupedExpression => {
const grouped = node.cast(ast.Node.GroupedExpression).?;
return try resolveTypeOfNode(store, arena, .{ .node = grouped.expr, .handle = handle });
},
.StructInitializer => {
const struct_init = node.cast(ast.Node.StructInitializer).?;
return try resolveTypeOfNode(store, arena, .{ .node = struct_init.lhs, .handle = handle });
@ -430,6 +434,13 @@ pub fn resolveTypeOfNode(store: *DocumentStore, arena: *std.heap.ArenaAllocator,
})) orelse return null;
return try resolveUnwrapOptionalType(store, arena, left_type);
},
.Catch => {
const left_type = (try resolveTypeOfNode(store, arena, .{
.node = infix_op.lhs,
.handle = handle,
})) orelse return null;
return try resolveUnwrapErrorType(store, arena, left_type);
},
.ErrorUnion => return node_handle,
else => return null,
}
@ -1305,7 +1316,13 @@ fn makeScopeInternal(
if (decl.cast(ast.Node.ContainerField)) |field| {
if (field.type_expr == null and field.value_expr == null) {
continue;
if (node.id == .Root) continue;
if (node.cast(ast.Node.ContainerDecl)) |container| {
const kind = tree.token_ids[container.kind_token];
if (kind == .Keyword_struct or (kind == .Keyword_union and container.init_arg_expr == .None)) {
continue;
}
}
}
}