fix crash with generic function and implicit cast

This commit is contained in:
Andrew Kelley
2016-04-14 10:39:03 -07:00
parent 83a59c4d07
commit fcedc35551
4 changed files with 22 additions and 5 deletions

View File

@@ -2927,6 +2927,7 @@ static void clone_subtree_list(ZigList<AstNode *> *dest, ZigList<AstNode *> *src
dest->resize(src->length);
for (int i = 0; i < src->length; i += 1) {
dest->at(i) = ast_clone_subtree(src->at(i), next_node_index);
dest->at(i)->parent_field = &dest->at(i);
}
}
@@ -2958,11 +2959,12 @@ AstNode *ast_clone_subtree(AstNode *old_node, uint32_t *next_node_index) {
memcpy(new_node, old_node, sizeof(AstNode));
new_node->create_index = *next_node_index;
*next_node_index += 1;
new_node->parent_field = nullptr;
switch (new_node->type) {
case NodeTypeRoot:
clone_subtree_list(&new_node->data.root.top_level_decls, &old_node->data.root.top_level_decls,
next_node_index);
clone_subtree_list(&new_node->data.root.top_level_decls,
&old_node->data.root.top_level_decls, next_node_index);
break;
case NodeTypeFnProto:
clone_subtree_tld(&new_node->data.fn_proto.top_level_decl, &old_node->data.fn_proto.top_level_decl,