From df283114717037fe397ca00f0ab4720dceed1681 Mon Sep 17 00:00:00 2001 From: andrei Date: Thu, 26 Dec 2024 20:28:47 +0200 Subject: [PATCH] eoc: clear deferred math on type errors too --- src/condition.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/condition.cpp b/src/condition.cpp index d6faf1a8dcff1..069d2e3826a87 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -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(); } } @@ -2483,10 +2483,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)" ); } }