diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 6be8a1b..8abca9a 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -406,7 +406,7 @@ namespace chaiscript m->add(fun(&dispatch::Dynamic_Object::get_attrs), "get_attrs"); m->add(fun(&dispatch::Dynamic_Object::get_attr), "get_attr"); - m->eval("def Dynamic_Object::clone() { auto new_o := Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }"); + m->eval("def Dynamic_Object::clone() { auto &new_o = Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }"); m->add(fun(&has_guard), "has_guard"); m->add(fun(&get_guard), "get_guard"); diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index aeeba9e..1b7cda1 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -335,7 +335,6 @@ namespace chaiscript m_engine.add_reserved_word("&&"); m_engine.add_reserved_word("||"); m_engine.add_reserved_word(","); - m_engine.add_reserved_word(":="); m_engine.add_reserved_word("auto"); m_engine.add_reserved_word("return"); m_engine.add_reserved_word("break"); diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index aaad2c8..3c7cd21 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -302,10 +302,11 @@ namespace chaiscript /// \todo This does not handle the case of an unassigned reference variable /// being assigned outside of its declaration lhs.assign(retval); + return retval; } else { retval = t_ss.call_function("clone", retval); + retval.clear_dependencies(); } - retval.clear_dependencies(); } try { @@ -319,13 +320,6 @@ namespace chaiscript throw exception::eval_error("Can not clone right hand side of equation"); } } - else if (this->children[1]->text == ":=") { - if (lhs.is_undef() || type_match(lhs, retval)) { - lhs.assign(retval); - } else { - throw exception::eval_error("Mismatched types in equation"); - } - } else { try { retval = t_ss.call_function(this->children[1]->text, lhs, retval); diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index eb4eda6..edd3f77 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -1889,7 +1889,7 @@ namespace chaiscript if (Operator()) { retval = true; - if (Symbol("=", true, true) || Symbol(":=", true, true) || Symbol("+=", true, true) || + if (Symbol("=", true, true) || Symbol("+=", true, true) || Symbol("-=", true, true) || Symbol("*=", true, true) || Symbol("/=", true, true) || Symbol("%=", true, true) || Symbol("<<=", true, true) || Symbol(">>=", true, true) || Symbol("&=", true, true) || Symbol("^=", true, true) || Symbol("|=", true, true)) { diff --git a/unittests/ref_equal.chai b/unittests/ref_equal.chai deleted file mode 100644 index 200991e..0000000 --- a/unittests/ref_equal.chai +++ /dev/null @@ -1,5 +0,0 @@ -auto i = 3 -auto j := i -j = 4 - -assert_equal(4, i) diff --git a/unittests/reflection_test.chai b/unittests/reflection_test.chai index a35649e..42566bc 100644 --- a/unittests/reflection_test.chai +++ b/unittests/reflection_test.chai @@ -1,14 +1,14 @@ load_module("reflection") -auto parser := ChaiScript_Parser() +auto& parser = ChaiScript_Parser() auto parse_success = parser.parse("3 + 4", "INPUT") -auto a := parser.ast() +auto& a = parser.ast() assert_equal(eval(a), 7) -auto childs := a.children.front().children -auto node := childs[0] +auto& childs = a.children.front().children +auto& node = childs[0] -auto parser2 := ChaiScript_Parser() +auto& parser2 = ChaiScript_Parser() parser2.parse("9", "INPUT") @@ -30,7 +30,7 @@ assert_equal(false, `+`.has_parse_tree()); assert_throws("Function does not have a parse tree", fun() { `+`.get_parse_tree(); } ); -auto parsetree := my_fun.get_parse_tree(); +auto& parsetree = my_fun.get_parse_tree(); assert_equal(1, eval(parsetree));