diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-08-17 00:31:55 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-08-17 00:31:55 +0200 |
| commit | a9f3f61ef7e0995a2f8ab30c461a502fa2176753 (patch) | |
| tree | 0fa49881f39929df0969743b47aceb2fb4b5c843 /src/server | |
| parent | 81e17b2aa1cf54a5a9226f1b3b766810008372d4 (diff) | |
Fix rare crash with semantic token
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 8 | ||||
| -rw-r--r-- | src/server/documents.odin | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 0873be4..3491557 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -920,7 +920,7 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (S case ^Ellipsis: return resolve_type_expression(ast_context, v.expr) case ^Implicit: - ident := new_type(Ident, v.node.pos, v.node.end, context.temp_allocator) + ident := new_type(Ident, v.node.pos, v.node.end, ast_context.allocator) ident.name = v.tok.text return resolve_type_identifier(ast_context, ident^) case ^Type_Assertion: @@ -1018,7 +1018,7 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (S } case SymbolProcedureValue: if len(s.return_types) == 1 { - selector_expr := new_type(ast.Selector_Expr, s.return_types[0].node.pos, s.return_types[0].node.end, context.temp_allocator) + selector_expr := new_type(ast.Selector_Expr, s.return_types[0].node.pos, s.return_types[0].node.end, ast_context.allocator) selector_expr.expr = s.return_types[0].type selector_expr.field = v.field return resolve_type_expression(ast_context, selector_expr) @@ -2281,9 +2281,9 @@ get_locals_using_stmt :: proc(stmt: ast.Using_Stmt, ast_context: ^AstContext) { } case SymbolStructValue: for name, i in v.names { - selector := new_type(ast.Selector_Expr, v.types[i].pos, v.types[i].end, context.temp_allocator) + selector := new_type(ast.Selector_Expr, v.types[i].pos, v.types[i].end, ast_context.allocator) selector.expr = u - selector.field = new_type(ast.Ident, v.types[i].pos, v.types[i].end, context.temp_allocator) + selector.field = new_type(ast.Ident, v.types[i].pos, v.types[i].end, ast_context.allocator) selector.field.name = name store_local(ast_context, u, selector, 0, name, ast_context.local_id) ast_context.variables[name] = true diff --git a/src/server/documents.odin b/src/server/documents.odin index d320cf0..d5b0f09 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -377,9 +377,13 @@ parse_document :: proc(document: ^Document, config: ^common.Config) -> ([]Parser current_errors = make([dynamic]ParserError, context.temp_allocator) - free_all(common.scratch_allocator(document.allocator)) + if document.uri.uri in file_resolve_cache.files { + key := file_resolve_cache.files[document.uri.uri] + delete_key(&file_resolve_cache.files, document.uri.uri) + delete(key) + } - delete_key(&file_resolve_cache.files, document.uri.uri) + free_all(common.scratch_allocator(document.allocator)) context.allocator = common.scratch_allocator(document.allocator) |