Sema: validate function parameter types and return type
This commit is contained in:
committed by
Andrew Kelley
parent
d851b24180
commit
8feb398760
@@ -2439,6 +2439,7 @@ pub const SrcLoc = struct {
|
||||
|
||||
.node_offset_fn_type_ret_ty => |node_off| {
|
||||
const tree = try src_loc.file_scope.getTree(gpa);
|
||||
const node_datas = tree.nodes.items(.data);
|
||||
const node_tags = tree.nodes.items(.tag);
|
||||
const node = src_loc.declRelativeToNodeIndex(node_off);
|
||||
var params: [1]Ast.Node.Index = undefined;
|
||||
@@ -2447,6 +2448,16 @@ pub const SrcLoc = struct {
|
||||
.fn_proto_multi => tree.fnProtoMulti(node),
|
||||
.fn_proto_one => tree.fnProtoOne(¶ms, node),
|
||||
.fn_proto => tree.fnProto(node),
|
||||
.fn_decl => blk: {
|
||||
const fn_proto = node_datas[node].lhs;
|
||||
break :blk switch (node_tags[fn_proto]) {
|
||||
.fn_proto_simple => tree.fnProtoSimple(¶ms, fn_proto),
|
||||
.fn_proto_multi => tree.fnProtoMulti(fn_proto),
|
||||
.fn_proto_one => tree.fnProtoOne(¶ms, fn_proto),
|
||||
.fn_proto => tree.fnProto(fn_proto),
|
||||
else => unreachable,
|
||||
};
|
||||
},
|
||||
else => unreachable,
|
||||
};
|
||||
return nodeToSpan(tree, full.ast.return_type);
|
||||
|
||||
Reference in New Issue
Block a user