Skip to content

Commit 429bcda

Browse files
gh-152: Make POW not write back pointer exponent.
Fix test passing/pow-pointer-writeback.pre.
1 parent 631c4d7 commit 429bcda

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/builtins.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,14 +3226,14 @@ static Value builtin_pow(Interpreter* interp, Value* args, int argc, Expr** arg_
32263226
exp >>= 1;
32273227
}
32283228
Value out = value_int_base(result, out_base);
3229-
if (!writeback_ptr_range(interp, arg_nodes, env, 0, 2, out, "POW", line, col)) {
3229+
if (!writeback_first_ptr(interp, arg_nodes, env, out, "POW", line, col)) {
32303230
value_free(out);
32313231
return value_null();
32323232
}
32333233
return out;
32343234
}
32353235
Value out = value_flt_base(pow(args[0].as.f, args[1].as.f), out_base);
3236-
if (!writeback_ptr_range(interp, arg_nodes, env, 0, 2, out, "POW", line, col)) {
3236+
if (!writeback_first_ptr(interp, arg_nodes, env, out, "POW", line, col)) {
32373237
value_free(out);
32383238
return value_null();
32393239
}
@@ -3424,7 +3424,7 @@ static Value builtin_ipow(Interpreter* interp, Value* args, int argc, Expr** arg
34243424
exp >>= 1;
34253425
}
34263426
Value out = value_int_base(result, result_base_from_values(args[0], args[1]));
3427-
if (!writeback_ptr_range(interp, arg_nodes, env, 0, 2, out, "IPOW", line, col)) {
3427+
if (!writeback_first_ptr(interp, arg_nodes, env, out, "IPOW", line, col)) {
34283428
value_free(out);
34293429
return value_null();
34303430
}
@@ -3439,7 +3439,7 @@ static Value builtin_fpow(Interpreter* interp, Value* args, int argc, Expr** arg
34393439
double a = args[0].type == VAL_FLT ? args[0].as.f : (double)args[0].as.i;
34403440
double b = args[1].type == VAL_FLT ? args[1].as.f : (double)args[1].as.i;
34413441
Value out = value_flt_base(pow(a, b), result_base_from_values(args[0], args[1]));
3442-
if (!writeback_ptr_range(interp, arg_nodes, env, 0, 2, out, "FPOW", line, col)) {
3442+
if (!writeback_first_ptr(interp, arg_nodes, env, out, "FPOW", line, col)) {
34433443
value_free(out);
34443444
return value_null();
34453445
}

tests/cases/passing/pow-pointer-writeback.pre

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ INT: a3 = 0d2
1212
INT: b3 = 0d3
1313
POW(@a3, @b3)
1414
ASSERT(EQ(a3, 0d8))
15-
ASSERT(EQ(b3, 0d8))
15+
ASSERT(EQ(b3, 0d3))
1616

1717
FLT: f1 = 0d1.5
1818
FLT: g1 = 0d2.0
@@ -28,4 +28,4 @@ FLT: f3 = 0d1.5
2828
FLT: g3 = 0d2.0
2929
POW(@f3, @g3)
3030
ASSERT(EQ(f3, 0d2.25))
31-
ASSERT(EQ(g3, 0d2.25))
31+
ASSERT(EQ(g3, 0d2.0))

0 commit comments

Comments
 (0)