-
Notifications
You must be signed in to change notification settings - Fork 137
Fix off-by-one error in stack traces by making line and column numbers 1-based for user display #2628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: minestarks <[email protected]>
…or user display Co-authored-by: minestarks <[email protected]>
@copilot can you add 1 to the column as well? Also, I don't think you need to add any new tests for this, just update the existing ones |
Co-authored-by: minestarks <[email protected]>
Done! Added 1 to column positions as well to make them 1-based and removed the new tests, keeping only the updated existing test. All 157 qsc tests pass. (commit 62e0d53) |
…olumn numbers Co-authored-by: minestarks <[email protected]>
…ons with 1-based line/column numbers Co-authored-by: minestarks <[email protected]>
@copilot can you pull from main and resolve conflicts? |
… numbers Co-authored-by: minestarks <[email protected]>
Stack traces were displaying both line and column numbers using 0-based indexing instead of the standard 1-based indexing expected by users and editors.
Problem
When a runtime error occurred, the stack trace would report incorrect line and column numbers that were off by one:
Before fix:
After fix:
Root Cause
The
format_call_stack
function insource/compiler/qsc/src/interpret/debug.rs
was displayingpos.line
andpos.column
(which are 0-based for internal calculations) directly to users. Both line and column numbers should be 1-based for user-facing display as this is the standard convention used by editors and IDEs.Solution
Updated both line and column number display to add 1 to convert from internal 0-based indexing to user-expected 1-based indexing:
This change ensures that both line and column numbers are displayed correctly to users while preserving the internal 0-based indexing used throughout the codebase.
Testing
Fixes #2627.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.