diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-20 10:49:40 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-20 10:49:40 +0000 |
| commit | f027a812707d68ca0690b7544175b9f302dd57ad (patch) | |
| tree | 8ca82006fa3213215ff7b70bec5e49e8421413ff /src/parser/parser_expr.c | |
| parent | 856198b2ea473a4fd2cd020e58db821265b21ca5 (diff) | |
Copy trait...
Diffstat (limited to 'src/parser/parser_expr.c')
| -rw-r--r-- | src/parser/parser_expr.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/parser/parser_expr.c b/src/parser/parser_expr.c index cc647c7..97d6218 100644 --- a/src/parser/parser_expr.c +++ b/src/parser/parser_expr.c @@ -9,7 +9,7 @@ Type *get_field_type(ParserContext *ctx, Type *struct_type, const char *field_name); -int is_type_copy(Type *t) +int is_type_copy(ParserContext *ctx, Type *t) { if (!t) { @@ -38,7 +38,11 @@ int is_type_copy(Type *t) return 1; case TYPE_STRUCT: - // Structs are MOVE by default + // Structs are MOVE by default unless they implement Copy + if (check_impl(ctx, "Copy", t->name)) + { + return 1; + } return 0; case TYPE_ARRAY: @@ -1829,7 +1833,7 @@ ASTNode *parse_primary(ParserContext *ctx, Lexer *l) } } - if (!is_type_copy(t)) + if (!is_type_copy(ctx, t)) { Symbol *s = find_symbol_entry(ctx, arg->var_ref.name); if (s) @@ -1960,7 +1964,7 @@ ASTNode *parse_primary(ParserContext *ctx, Lexer *l) } } - if (!is_type_copy(t)) + if (!is_type_copy(ctx, t)) { Symbol *s = find_symbol_entry(ctx, arg->var_ref.name); if (s) @@ -2246,7 +2250,7 @@ ASTNode *parse_primary(ParserContext *ctx, Lexer *l) } } - if (!is_type_copy(t)) + if (!is_type_copy(ctx, t)) { Symbol *s = find_symbol_entry(ctx, arg->var_ref.name); if (s) @@ -3347,7 +3351,7 @@ ASTNode *parse_expr_prec(ParserContext *ctx, Lexer *l, Precedence min_prec) } } - if (!is_type_copy(t)) + if (!is_type_copy(ctx, t)) { Symbol *s = find_symbol_entry(ctx, arg->var_ref.name); if (s) @@ -3753,7 +3757,7 @@ ASTNode *parse_expr_prec(ParserContext *ctx, Lexer *l, Precedence min_prec) } } - if (!is_type_copy(t)) + if (!is_type_copy(ctx, t)) { Symbol *s = find_symbol_entry(ctx, rhs->var_ref.name); if (s) |
