Skip to content

Commit

Permalink
Fix a bug I introduced for dc in a recent fix
Browse files Browse the repository at this point in the history
This bug was introduced in 2b00094. It
made it so dc was not doing the right thing when copying a variable.
  • Loading branch information
Gavin Howard committed Jun 30, 2019
1 parent 22e5170 commit ce1b5a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,20 @@ static BcStatus bc_program_copyToVar(BcProgram *p, size_t idx,
bool var = (t == BC_TYPE_VAR);

#if BC_ENABLED
#if DC_ENABLED
if (!BC_IS_BC) s = bc_program_operand(p, &ptr, &n, 0);
else
#endif // DC_ENABLED
{
ptr = bc_vec_top(&p->results);

ptr = bc_vec_top(&p->results);

s = bc_program_type_match(ptr, t);
if (BC_ERR(s)) return s;
s = bc_program_type_match(ptr, t);
if (BC_ERR(s)) return s;

if (last) s = bc_program_num(p, ptr, &n);
else if (var) n = bc_vec_item_rev(bc_program_vec(p, ptr->d.loc.loc, t), 1);
if (last) s = bc_program_num(p, ptr, &n);
else if (var)
n = bc_vec_item_rev(bc_program_vec(p, ptr->d.loc.loc, t), 1);
}
#else // BC_ENABLED
s = bc_program_operand(p, &ptr, &n, 0);
#endif // BC_ENABLED
Expand Down
7 changes: 7 additions & 0 deletions tests/dc/errors/21.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
0bpR
1bpR
.218933bpR
138963.9873645bpR
S19bpR
_.1298376bpR
_3892173.289375bpR

0 comments on commit ce1b5a5

Please sign in to comment.