Correctly handle tab indentation when printing error locations #837

Open
opened 2025-05-21 10:30:48 +00:00 by piegames · 0 comments
Member

Describe the bug

First discovered in https://gerrit.lix.systems/c/lix/+/3200/1.

Basically, the current error location printer (also used for warnings) is naive and simply treats tabs like any other one-wide character. This is obviously wrong, and results in badly aligned error messages.

Steps To Reproduce

Have a tab-indented file with a parser error or warning

[
	# Should warn
	{ a = rec {}; a.__overrides = {}; }
]

The "Should warn" comment is completely misaligned

warning: __overrides attributes are deprecated and will be removed in the future. Use --extra-deprecated-features rec-set-overrides to silence this warning.
         at «stdin»:3:16:
              2|         # Should warn
              3|  { a = rec {}; a.__overrides = {}; }
               |                ^
## Describe the bug First discovered in https://gerrit.lix.systems/c/lix/+/3200/1. Basically, the current error location printer (also used for warnings) is naive and simply treats tabs like any other one-wide character. This is obviously wrong, and results in badly aligned error messages. ## Steps To Reproduce Have a tab-indented file with a parser error or warning ```nix [ # Should warn { a = rec {}; a.__overrides = {}; } ] ``` The "Should warn" comment is completely misaligned ``` warning: __overrides attributes are deprecated and will be removed in the future. Use --extra-deprecated-features rec-set-overrides to silence this warning. at «stdin»:3:16: 2| # Should warn 3| { a = rec {}; a.__overrides = {}; } | ^ ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#837
No description provided.