Skip to content

Commit

Permalink
Merge pull request #78775 from andrei8l/clear-deferred-math-part2
Browse files Browse the repository at this point in the history
eoc: clear deferred math on type errors too
  • Loading branch information
Maleclypse authored Dec 27, 2024
2 parents 8bd4c5d + df28311 commit 163ee18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,12 @@ void finalize_conditions()
deferred_math &math = dfr.front();
try {
math.exp->parse( math.str, false );
math._validate_type();
} catch( math::exception const &ex ) {
JsonObject jo{ std::move( math.jo ) };
clear_deferred_math();
jo.throw_error_at( "math", ex.what() );
}
math._validate_type();
dfr.pop();
}
}
Expand Down Expand Up @@ -2482,10 +2482,10 @@ void deferred_math::_validate_type() const
{
math_type_t exp_type = exp->get_type();
if( exp_type == math_type_t::assign && type != math_type_t::assign ) {
jo.throw_error_at( "math",
R"(Assignment operators can't be used in this context. Did you mean to use "=="? )" );
throw math::syntax_error(
R"(Assignment operators can't be used in this context. Did you mean to use "=="? )" );
} else if( exp_type != math_type_t::assign && type == math_type_t::assign ) {
jo.throw_error_at( "math", R"(Eval statement in assignment context has no effect)" );
throw math::syntax_error( R"(Eval statement in assignment context has no effect)" );
}
}

Expand Down

0 comments on commit 163ee18

Please sign in to comment.