mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-07 13:48:33 +02:00
Eval
- Better error message for malformed expressions, ie when a binary operator expects two values, and sees less then two or when a unary operator sees less than one.
This commit is contained in:
parent
071cf55c00
commit
9e0ea1cb4a
1 changed files with 9 additions and 0 deletions
|
@ -243,6 +243,9 @@ void Eval::evaluatePostfixStack (
|
||||||
if (token->second == Lexer::typeOperator &&
|
if (token->second == Lexer::typeOperator &&
|
||||||
token->first == "!")
|
token->first == "!")
|
||||||
{
|
{
|
||||||
|
if (values.size () < 1)
|
||||||
|
throw std::string (STRING_EVAL_NO_EVAL);
|
||||||
|
|
||||||
Variant right = values.back ();
|
Variant right = values.back ();
|
||||||
values.pop_back ();
|
values.pop_back ();
|
||||||
if (_debug)
|
if (_debug)
|
||||||
|
@ -256,6 +259,9 @@ void Eval::evaluatePostfixStack (
|
||||||
else if (token->second == Lexer::typeOperator &&
|
else if (token->second == Lexer::typeOperator &&
|
||||||
token->first == "_neg_")
|
token->first == "_neg_")
|
||||||
{
|
{
|
||||||
|
if (values.size () < 1)
|
||||||
|
throw std::string (STRING_EVAL_NO_EVAL);
|
||||||
|
|
||||||
Variant right = values.back ();
|
Variant right = values.back ();
|
||||||
values.pop_back ();
|
values.pop_back ();
|
||||||
if (_debug)
|
if (_debug)
|
||||||
|
@ -279,6 +285,9 @@ void Eval::evaluatePostfixStack (
|
||||||
// Binary operators.
|
// Binary operators.
|
||||||
else if (token->second == Lexer::typeOperator)
|
else if (token->second == Lexer::typeOperator)
|
||||||
{
|
{
|
||||||
|
if (values.size () < 2)
|
||||||
|
throw std::string (STRING_EVAL_NO_EVAL);
|
||||||
|
|
||||||
Variant right = values.back ();
|
Variant right = values.back ();
|
||||||
values.pop_back ();
|
values.pop_back ();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue