wavefnd / wavefnd/Wave

Align diagnostic carets with tabs and wide Unicode characters

Open
#489 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted ui/ux
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

## Reproduction

On #486 head `6fb6ed7`, write a tab-indented source file (the `\t` below must be an actual tab):

```python
from pathlib import Path
Path('/tmp/tab-caret.wave').write_text('fun main() {\n\tmissing;\n}\n')
```

Then run:

```bash
target/release/wavec check /tmp/tab-caret.wave
```

The compiler correctly reports `:2:2` in Unicode scalar coordinates. The source row contains a literal tab, but the caret row uses one ordinary space, so the underline appears before the identifier in a terminal. A second reproducer is:

```wave
fun main() {
var 이름: i32 = 1; 이름; missing;
}
```

Its stored scalar column is correctly 26, but the preceding Korean characters occupy two terminal cells each and the underline is visually displaced.

## Cause and scope

`front/error/src/error.rs::display_source_block` prints source lines verbatim and pads the caret with `column - 1` spaces. It uses source-coordinate counts as display widths. #406/#486 fix which source occurrence is selected; this follow-up concerns terminal rendering only.

## Acceptance

- [ ] Compute caret display offsets from the actual source prefix, including tabs and wide characters, with a documented tab policy.
- [ ] Apply the same rule to full-source and single-line diagnostic rendering.
- [ ] Add focused output tests for a tab-indented error, wide characters before an error and ordinary ASCII.
- [ ] Preserve UTF-8 byte spans and one-based Unicode scalar coordinates in JSON; do not convert the machine-readable location contract to terminal cells.
- [ ] Keep the underline immediately after the failing source row.

Start with `front/error/src/error.rs` and `tests/frontend_regressions.rs`. Related documentation task #404 remains separate.

Contributor guide

Open the contributing guide

Research direction

Start with front/error/src/error.rs, especially display_source_block, and review the related cases in tests/frontend_regressions.rs. Run the tab, wide-character, and ASCII reproducers to compare source coordinates with terminal output. Done means both rendering paths align carets using a documented tab policy while JSON retains its existing UTF-8 spans and one-based scalar coordinates.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.