Fix erronously using the name of the properties instead of the typename for lookup

This commit is contained in:
2024-06-09 22:11:56 +02:00
parent b81c0af596
commit b1dceb298f
2 changed files with 9 additions and 3 deletions

View File

@@ -277,6 +277,8 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
case .Variable; { case .Variable; {
indent(*state.builder, indentation); indent(*state.builder, indentation);
type_var := h2tv(state.type_variables, node.type_variable);
print("type: %\n", type_var.typename);
is_properties := node.name == "properties"; is_properties := node.name == "properties";
if !is_properties { if !is_properties {

View File

@@ -920,7 +920,7 @@ declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Va
name := ifx node.name.count == 0 then "properties" else node.name; name := ifx node.name.count == 0 then "properties" else node.name;
type_var := declare_struct(checker, node, name); type_var := declare_struct(checker, node, name);
var := h2tv(checker, type_var); var := h2tv(checker, type_var);
var.typename = name; var.typename = "properties";
var.buffer_index = 0; var.buffer_index = 0;
return type_var; return type_var;
} }
@@ -1204,7 +1204,11 @@ create_variable :: (checker : *Semantic_Checker, node : *AST_Node, field_parent
field_access_on_primitive_type(checker, node, find_result.type_variable); field_access_on_primitive_type(checker, node, find_result.type_variable);
return 0; return 0;
} else { } else {
struct_symbol := find_symbol(checker, variable.typename, checker.current_scope); lookup_name : string;
if variable.typename == "properties" {
lookup_name = variable.name;
}
struct_symbol := find_symbol(checker, lookup_name, checker.current_scope);
type_variable := h2tv(checker, struct_symbol.type_variable); type_variable := h2tv(checker, struct_symbol.type_variable);
previous_scope := use_scope(checker, type_variable.scope); previous_scope := use_scope(checker, type_variable.scope);