diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-17 17:49:08 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-17 17:49:08 -0400 |
commit | 78813fc6169f70b804b917b57ded2b9f5b2fb124 (patch) | |
tree | 9447803b6d49c6285d406ff33f3f7354d78b545e /valexpr.cc | |
parent | 6815aac361180be49f671c2a39106c723a861247 (diff) | |
download | fork-ledger-78813fc6169f70b804b917b57ded2b9f5b2fb124.tar.gz fork-ledger-78813fc6169f70b804b917b57ded2b9f5b2fb124.tar.bz2 fork-ledger-78813fc6169f70b804b917b57ded2b9f5b2fb124.zip |
Rather than just aborting, report an intelligent error if the comma operator
is missing one of its operands in a value expression. This kind of reporting
still needs to be done for all the other operators as well.
Diffstat (limited to 'valexpr.cc')
-rw-r--r-- | valexpr.cc | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -578,8 +578,12 @@ void value_expr_t::compute(value_t& result, const details_t& details, } case O_COM: - assert(left); - assert(right); + if (! left) + throw new compute_error("Comma operator missing left operand", + new valexpr_context(this)); + if (! right) + throw new compute_error("Comma operator missing right operand", + new valexpr_context(this)); left->compute(result, details, context); right->compute(result, details, context); break; @@ -1731,10 +1735,12 @@ bool write_value_expr(std::ostream& out, break; case value_expr_t::O_COM: - if (write_value_expr(out, node->left, relaxed, node_to_find, start_pos, end_pos)) + if (node->left && + write_value_expr(out, node->left, relaxed, node_to_find, start_pos, end_pos)) found = true; out << ", "; - if (write_value_expr(out, node->right, relaxed, node_to_find, start_pos, end_pos)) + if (node->right && + write_value_expr(out, node->right, relaxed, node_to_find, start_pos, end_pos)) found = true; break; case value_expr_t::O_QUES: |