Skip to content

Commit

Permalink
Merge pull request #77445 from andrei8l/clear-deferred-math
Browse files Browse the repository at this point in the history
eoc: clear deferred math on error
  • Loading branch information
Maleclypse authored Oct 31, 2024
2 parents 8fa34a4 + 247f1d8 commit b321b17
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ std::queue<deferred_math> &get_deferred_math()
return dfr_math;
}

void clear_deferred_math()
{
std::queue<deferred_math> empty;
get_deferred_math().swap( empty );
}

std::shared_ptr<math_exp> &defer_math( JsonObject const &jo, std::string_view str, bool ass )
{
get_deferred_math().emplace( jo, str, ass );
Expand Down Expand Up @@ -581,7 +587,9 @@ void finalize_conditions()
try {
math.exp->parse( math.str, math.assignment, false );
} catch( std::invalid_argument const &ex ) {
math.jo.throw_error_at( "math", ex.what() );
JsonObject jo{ std::move( math.jo ) };
clear_deferred_math();
jo.throw_error_at( "math", ex.what() );
}
dfr.pop();
}
Expand Down

0 comments on commit b321b17

Please sign in to comment.