Fix for update assignments
This commit is contained in:
parent
e38ecde989
commit
357c9faa40
@ -359,7 +359,7 @@ static CORD compile_lvalue(env_t *env, ast_t *ast)
|
||||
} else {
|
||||
code_err(ast, "I don't know how to assign to this target");
|
||||
}
|
||||
} else if (ast->tag == Var || ast->tag == FieldAccess) {
|
||||
} else if (ast->tag == Var || ast->tag == FieldAccess || ast->tag == InlineCCode) {
|
||||
return compile(env, ast);
|
||||
} else {
|
||||
code_err(ast, "I don't know how to assign to this");
|
||||
@ -610,7 +610,7 @@ CORD compile_statement(env_t *env, ast_t *ast)
|
||||
type_t *lhs_t = get_type(env, Match(test->expr, UpdateAssign)->lhs);
|
||||
auto update = Match(test->expr, UpdateAssign);
|
||||
ast_t *update_var = WrapAST(ast, UpdateAssign,
|
||||
.lhs=WrapAST(update->lhs, Index, .indexed=WrapAST(update->lhs, InlineCCode, .code="expr", .type=Type(PointerType, lhs_t))),
|
||||
.lhs=WrapAST(update->lhs, InlineCCode, .code="(*expr)", .type=lhs_t),
|
||||
.op=update->op, .rhs=update->rhs);
|
||||
return CORD_asprintf(
|
||||
"test(({%r = &(%r); %r; *expr;}), %r, %r, %ld, %ld);",
|
||||
|
@ -1292,6 +1292,7 @@ PUREFUNC bool can_be_mutated(env_t *env, ast_t *ast)
|
||||
{
|
||||
switch (ast->tag) {
|
||||
case Var: return true;
|
||||
case InlineCCode: return true;
|
||||
case FieldAccess: {
|
||||
auto access = Match(ast, FieldAccess);
|
||||
type_t *fielded_type = get_type(env, access->fielded);
|
||||
|
Loading…
Reference in New Issue
Block a user