diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 44116735..fb75a933 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -26,10 +26,6 @@ namespace chaiscript { struct AST_Node; - struct AST_Node_Trace; - namespace exception { - struct eval_error; - } } // namespace chaiscript namespace chaiscript { diff --git a/unittests/compiled_tests.cpp b/unittests/compiled_tests.cpp index 27a99585..4c7d96fa 100644 --- a/unittests/compiled_tests.cpp +++ b/unittests/compiled_tests.cpp @@ -1436,3 +1436,23 @@ TEST_CASE("Issue #421 - Switch with type_conversion does not compare destroyed o result })") == 0); } + +// Regression test for issue #607: AST_Node_Trace must be a complete type +// when used in eval_error's std::vector call_stack member. +// This failed to compile with C++20 on clang/libc++ when AST_Node_Trace +// was only forward-declared before eval_error's definition. +TEST_CASE("eval_error with AST_Node_Trace call stack compiles in C++20") { + chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser()); + + // Trigger an eval_error by calling a non-existent function + try { + chai.eval("nonexistent_function()"); + REQUIRE(false); + } catch (const chaiscript::exception::eval_error &e) { + // Verify that eval_error's call_stack member (std::vector) + // is usable - this would fail to compile if AST_Node_Trace were incomplete + const auto &stack = e.call_stack; + CHECK(e.pretty_print().size() > 0); + (void)stack; + } +}