diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-23 09:38:10 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-24 08:55:23 -0400 |
| commit | 0d7f28a8ca38fbdd4baa522ec1caf9316d090d19 (patch) | |
| tree | f191c7139e18154e556bb8742eb1cc0cafa1e118 /src/server/analysis.odin | |
| parent | e239a9a74e732d91cc3e7e1c4b2dc68da1f2cb4c (diff) | |
Check types before adding pointer completion
Diffstat (limited to 'src/server/analysis.odin')
| -rw-r--r-- | src/server/analysis.odin | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 053273a..d65a410 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -408,7 +408,12 @@ are_symbol_basic_same_keywords :: proc(a, b: Symbol) -> bool { return true } -is_symbol_same_typed :: proc(ast_context: ^AstContext, a, b: Symbol, flags: ast.Field_Flags = {}) -> bool { +is_symbol_same_typed :: proc( + ast_context: ^AstContext, + a, b: Symbol, + flags: ast.Field_Flags = {}, + ignore_pointers := false, +) -> bool { // In order to correctly equate the symbols for overloaded functions, we need to check both directions if same, ok := are_symbol_untyped_basic_same_typed(a, b); ok { return same @@ -423,7 +428,7 @@ is_symbol_same_typed :: proc(ast_context: ^AstContext, a, b: Symbol, flags: ast. return false } - if a.pointers != b.pointers { + if !ignore_pointers && a.pointers != b.pointers { return false } @@ -438,11 +443,11 @@ is_symbol_same_typed :: proc(ast_context: ^AstContext, a, b: Symbol, flags: ast. #partial switch b_value in b.value { case SymbolBasicValue: if .Any_Int in flags { - //Temporary - make a function that finds the base type of basic values - //This code only works with non distinct ints - switch a.name { - case "int", "uint", "u32", "i32", "u8", "i8", "u64", "u16", "i16": - return true + names := untyped_map[.Integer] + for name in names { + if a.name == name { + return true + } } } } @@ -453,7 +458,8 @@ is_symbol_same_typed :: proc(ast_context: ^AstContext, a, b: Symbol, flags: ast. #partial switch a_value in a.value { case SymbolBasicValue: - return a.name == b.name && a.pkg == b.pkg + b_value := b.value.(SymbolBasicValue) + return a_value.ident.name == b_value.ident.name && a.pkg == b.pkg case SymbolStructValue, SymbolEnumValue, SymbolUnionValue, SymbolBitSetValue: return a.name == b.name && a.pkg == b.pkg case SymbolSliceValue: |