Improved Tcl stacktraces#3612
Open
zuiderkwast wants to merge 4 commits into
Open
Conversation
Generate stack traces with filenames and absolute line numbers. Examples: ``` % ./runtest --single tests/unit/auth.tcl Cleanup: may take some time... OK Starting test server at port 21079 [ready]: 48510 Testing unit/auth [ok]: AUTH fails if there is no password configured server side (0 ms) [exception]: Executing test client: invalid command name "dummy_undefined_function". in dummy_undefined_function at tests/unit/auth.tcl:6 in start_server at tests/support/server.tcl:766 in execute_test_file at tests/unit/auth.tcl:1 in execute_test_file at tests/test_helper.tcl:146 in test_client_main at tests/test_helper.tcl:645 in test_client_main at tests/test_helper.tcl:1062 in catch at tests/test_helper.tcl:1062 in if at tests/test_helper.tcl:1061 % ./runtest --single tests/unit/auth.tcl Cleanup: may take some time... OK Starting test server at port 21079 [ready]: 52538 Testing unit/auth [exception]: Executing test client: Bad protocol, 'N' as reply type byte. in valkey::__dispatch__ at tests/support/valkey.tcl:116 in $fd at tests/unit/auth.tcl:4 in test at tests/support/test.tcl:262 in test at tests/unit/auth.tcl:2 in start_server at tests/support/server.tcl:766 in execute_test_file at tests/unit/auth.tcl:1 in execute_test_file at tests/test_helper.tcl:146 in test_client_main at tests/test_helper.tcl:645 in test_client_main at tests/test_helper.tcl:1062 in catch at tests/test_helper.tcl:1062 in if at tests/test_helper.tcl:1061 ``` Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
The previous implementation reconstructed args from parsed opts + result,
which broke 'return {*}$args' patterns where multiple positional arguments
are passed (as seen in the failure in the scripting tests).
Now we only inject/modify -level in the original args list and pass
everything else through unchanged to orig_return.
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
48a4db2 to
63db390
Compare
sarthakaggarwal97
approved these changes
May 6, 2026
Contributor
sarthakaggarwal97
left a comment
There was a problem hiding this comment.
I support this idea!
- Only override return on Tcl 8.6+ where tailcall is available. This avoids the -level bump hack that broke package loading and other Tcl internals using uplevel + return -code error. - On Tcl 8.5, return is not overridden; only error is overridden. return -code error traces degrade to $::errorInfo on 8.5. - error override now calls orig_error directly instead of going through return -code error, making it work on all Tcl versions. Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Tcl's return treats args as a dict with an optional trailing result value (odd element). Use this directly instead of manual flag parsing. Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3612 +/- ##
============================================
- Coverage 76.90% 76.65% -0.26%
============================================
Files 162 162
Lines 80612 80614 +2
============================================
- Hits 61996 61792 -204
- Misses 18616 18822 +206 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generate stack traces with filenames and absolute line numbers.
Examples, with exceptions inserted in the test suite: