diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-12 07:33:53 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-12 07:33:53 -0400 |
| commit | 6bdd9d0e01cc19d0a322520aca79b16532bb866f (patch) | |
| tree | 87e2529b7eb50d97a45a996179ee7d083f66ac04 /src | |
| parent | d5ef3f6b4a782c5baf3a953425046a77e896db6f (diff) | |
Fix issue merging attributes
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/ast.odin | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/server/ast.odin b/src/server/ast.odin index 5c94bc1..28591f0 100644 --- a/src/server/ast.odin +++ b/src/server/ast.odin @@ -308,12 +308,15 @@ unwrap_attr_elem :: proc(elem: ^ast.Expr) -> (^ast.Ident, ^ast.Expr, bool) { return nil, nil, false } -merge_attributes :: proc(attrs: ^[dynamic]^ast.Attribute, foreign_attrs: []^ast.Attribute) { +merge_attributes :: proc(attrs: []^ast.Attribute, foreign_attrs: []^ast.Attribute) -> []^ast.Attribute { if len(foreign_attrs) == 0 { - return + return attrs } - attr_names := make(map[string]bool) + + new_attrs := make([dynamic]^ast.Attribute, context.temp_allocator) + attr_names := make(map[string]bool, context.temp_allocator) for attr in attrs { + append(&new_attrs, attr) for elem in attr.elems { if ident, _, ok := unwrap_attr_elem(elem); ok { attr_names[ident.name] = true @@ -333,11 +336,12 @@ merge_attributes :: proc(attrs: ^[dynamic]^ast.Attribute, foreign_attrs: []^ast. elems := make([dynamic]^ast.Expr) append(&elems, elem) new_attr.elems = elems[:] - append(attrs, new_attr) + append(&new_attrs, new_attr) } } } } + return new_attrs[:] } collect_value_decl :: proc( @@ -355,17 +359,17 @@ collect_value_decl :: proc( } comment, _ := get_file_comment(file, value_decl.pos.line) - merge_attributes(&value_decl.attributes, foreign_attrs) + attributes := merge_attributes(value_decl.attributes[:], foreign_attrs) global_expr := GlobalExpr { mutable = value_decl.is_mutable, docs = value_decl.docs, comment = comment, - attributes = value_decl.attributes[:], + attributes = attributes, private = file_tags.private, } - for attribute in value_decl.attributes { + for attribute in attributes { for elem in attribute.elems { ident, value, ok := unwrap_attr_elem(elem) if !ok { |