Skip to content

Fix #61: Thoroughly test throwing of exceptions from various contexts#681

Merged
lefticus merged 1 commit intoChaiScript:developfrom
leftibot:fix/issue-61-thoroughly-test-throwing-of-exceptions-f
Apr 14, 2026
Merged

Fix #61: Thoroughly test throwing of exceptions from various contexts#681
lefticus merged 1 commit intoChaiScript:developfrom
leftibot:fix/issue-61-thoroughly-test-throwing-of-exceptions-f

Conversation

@leftibot
Copy link
Copy Markdown
Contributor

Automated fix by @leftibot.

What changed

Fix #61: Comprehensive exception test suite and fix for silently swallowed exceptions
When all typed catch blocks failed to match a thrown exception's type,
handle_exception() would silently discard the exception and return a
default-constructed Boxed_Value instead of propagating it. This meant
code like try { throw(42) } catch(string e) { } would swallow the
int exception rather than letting it propagate to an outer handler.
The fix adds an explicit re-throw when no catch block matches, and
restructures eval_internal() with a nested try/catch to ensure the
finally block still executes before the unhandled exception propagates.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Files

 include/chaiscript/language/chaiscript_eval.hpp |  34 +-
 unittests/compiled_tests.cpp                    | 188 ++++++
 unittests/exception_comprehensive.chai          | 862 ++++++++++++++++++++++++
 3 files changed, 1070 insertions(+), 14 deletions(-)

Closes #61

Triggered by @lefticus.

…ently swallowed exceptions

When all typed catch blocks failed to match a thrown exception's type,
handle_exception() would silently discard the exception and return a
default-constructed Boxed_Value instead of propagating it. This meant
code like `try { throw(42) } catch(string e) { }` would swallow the
int exception rather than letting it propagate to an outer handler.

The fix adds an explicit re-throw when no catch block matches, and
restructures eval_internal() with a nested try/catch to ensure the
finally block still executes before the unhandled exception propagates.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@lefticus lefticus merged commit d4c5bdb into ChaiScript:develop Apr 14, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thoroughly test throwing of exceptions from various contexts

2 participants