Fixed infinite loop

This commit is contained in:
Alexandros Naskos 2020-06-18 03:23:56 +03:00
parent 5e7fc18404
commit 6c718a59c4
2 changed files with 22 additions and 15 deletions

View File

@ -580,6 +580,10 @@ fn resolveTypeOfNodeInternal(
} }
if (try lookupSymbolGlobal(store, arena, handle, handle.tree.getNodeSource(node), handle.tree.token_locs[node.firstToken()].start)) |child| { if (try lookupSymbolGlobal(store, arena, handle, handle.tree.getNodeSource(node), handle.tree.token_locs[node.firstToken()].start)) |child| {
switch(child.decl.*) {
.ast_node => |n| if (n == node) return null,
else => {},
}
return try child.resolveType(store, arena, bound_type_params); return try child.resolveType(store, arena, bound_type_params);
} }
return null; return null;

View File

@ -254,21 +254,24 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D
return try writeToken(builder, node.firstToken(), .parameter); return try writeToken(builder, node.firstToken(), .parameter);
} }
// TODO: Clean this up. // TODO: Clean this up.
// @TODO This stack overflows var bound_type_params = analysis.BoundTypeParams.init(&arena.allocator);
// var bound_type_params = analysis.BoundTypeParams.init(&arena.allocator);
// if (try child.resolveType(store, arena, &bound_type_params)) |decl_type| { var resolve_type_frame = try arena.child_allocator.alignedAlloc(u8, std.Target.stack_align, @sizeOf(@Frame(analysis.DeclWithHandle.resolveType)));
// if (decl_type.type.is_type_val) { defer arena.child_allocator.free(resolve_type_frame);
// const tok_type = if (decl_type.isStructType())
// .@"struct" if (try child.resolveType(store, arena, &bound_type_params)) |decl_type| {
// else if (decl_type.isEnumType()) if (decl_type.type.is_type_val) {
// .@"enum" const tok_type = if (decl_type.isStructType())
// else if (decl_type.isUnionType()) .@"struct"
// .@"union" else if (decl_type.isEnumType())
// else .@"enum"
// TokenType.type; else if (decl_type.isUnionType())
// return try writeTokenMod(builder, node.firstToken(), tok_type, .{}); .@"union"
// } else
// } TokenType.type;
return try writeTokenMod(builder, node.firstToken(), tok_type, .{});
}
}
} }
}, },
.FnProto => { .FnProto => {