diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index f368d62f..a99c4ebb 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -1280,7 +1280,7 @@ namespace chaiscript auto &catch_block = *this->children[i]; if (catch_block.children.size() == 1) { - //No variable capture, no guards + //No variable capture retval = catch_block.children[0]->eval(t_ss); break; } else if (catch_block.children.size() == 2 || catch_block.children.size() == 3) { @@ -1293,27 +1293,10 @@ namespace chaiscript t_ss.add_object(name, t_except); if (catch_block.children.size() == 2) { - //Variable capture, no guards + //Variable capture retval = catch_block.children[1]->eval(t_ss); break; } - else if (catch_block.children.size() == 3) { - //Variable capture, guards - - bool guard = false; - try { - guard = boxed_cast(catch_block.children[1]->eval(t_ss)); - } catch (const exception::bad_boxed_cast &) { - if (this->children.back()->identifier == AST_Node_Type::Finally) { - this->children.back()->children[0]->eval(t_ss); - } - throw exception::eval_error("Guard condition not boolean"); - } - if (guard) { - retval = catch_block.children[2]->eval(t_ss); - break; - } - } } } else { diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 749ac9d3..77386c3e 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -1715,11 +1715,6 @@ namespace chaiscript if (!(Arg() && Char(')'))) { throw exception::eval_error("Incomplete 'catch' expression", File_Position(m_position.line, m_position.col), *m_filename); } - if (Char(':')) { - if (!Operator()) { - throw exception::eval_error("Missing guard expression for catch", File_Position(m_position.line, m_position.col), *m_filename); - } - } } while (Eol()) {} diff --git a/unittests/3.x/exception_guards.chai b/unittests/3.x/exception_guards.chai deleted file mode 100644 index 99cd9018..00000000 --- a/unittests/3.x/exception_guards.chai +++ /dev/null @@ -1,34 +0,0 @@ -var results = []; - -for (var i = 2; i < 6; ++i) { - try { - throw(i) - } - catch(e) : e < 2 { - results.push_back("c1: " + e.to_string()); - } - catch(e) : e < 4 { - results.push_back("c2: " + e.to_string()); - } - catch(e) { - results.push_back("c3: " + e.to_string()); - } - catch { - // Should never get called - assert_equal(false, true) - } -} - -try { - throw(3) -} -catch(e) : e < 3 -{ - // Should never get called - assert_equal(false, true); -} -catch { - results.push_back("defaultcatch"); -} - -assert_equal(["c2: 2", "c2: 3", "c3: 4", "c3: 5", "defaultcatch"], results); diff --git a/unittests/exception_guards.chai b/unittests/exception_guards.chai deleted file mode 100644 index 12792985..00000000 --- a/unittests/exception_guards.chai +++ /dev/null @@ -1,34 +0,0 @@ -auto results = []; - -for (auto i = 2; i < 6; ++i) { - try { - throw(i) - } - catch(e) : e < 2 { - results.push_back("c1: " + e.to_string()); - } - catch(e) : e < 4 { - results.push_back("c2: " + e.to_string()); - } - catch(e) { - results.push_back("c3: " + e.to_string()); - } - catch { - // Should never get called - assert_equal(false, true) - } -} - -try { - throw(3) -} -catch(e) : e < 3 -{ - // Should never get called - assert_equal(false, true); -} -catch { - results.push_back("defaultcatch"); -} - -assert_equal(["c2: 2", "c2: 3", "c3: 4", "c3: 5", "defaultcatch"], results); diff --git a/unittests/exception_typed_2.chai b/unittests/exception_typed_2.chai deleted file mode 100644 index cb294c78..00000000 --- a/unittests/exception_typed_2.chai +++ /dev/null @@ -1,34 +0,0 @@ -auto results = []; - -for (auto i = 2; i < 6; ++i) { - try { - throw(i) - } - catch(int e) : e < 2 { - results.push_back("c1: " + e.to_string()); - } - catch(int e) : e < 4 { - results.push_back("c2: " + e.to_string()); - } - catch(e) { - results.push_back("c3: " + e.to_string()); - } - catch { - // Should never get called - assert_equal(false, true) - } -} - -try { - throw(3) -} -catch(int e) : e < 3 -{ - // Should never get called - assert_equal(false, true); -} -catch { - results.push_back("defaultcatch"); -} - -assert_equal(["c2: 2", "c2: 3", "c3: 4", "c3: 5", "defaultcatch"], results);