wavefnd / wavefnd/Wave

Return an ordered empty range when trim_range receives only whitespace

Open
#548 0 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

`trim_range` combines `trim_left_index` and `trim_right_index` without reconciling an empty result. For three spaces, the helpers intentionally return 3 and 0 respectively; `trim_range` therefore exposes start=3, end=0. A caller calculating the trimmed length as end-start gets -3 rather than an empty range.

The individual helper behavior is already asserted by shared/test99 and need not change. The missing behavior belongs in the combined range API.

Code evidence:

- [std/string/trim.wave:61](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/string/trim.wave#L61)
- [tests/cases/shared/test99.wave:15](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/tests/cases/shared/test99.wave#L15)

Acceptance:

- [ ] Normalize the combined empty result to an ordered zero-length range, with a short comment stating which empty offset is returned.
- [ ] Cover empty input, all spaces, mixed supported whitespace, padded content and content without whitespace.
- [ ] Assert 0 <= start <= end <= input length and preserve the existing individual left/right helper results.
- [ ] Do not expand this patch into changing the set of whitespace characters or adding string dependencies.

Audit status: static source inspection against canonical master `ea74c2dafc31da876e5561f2d176ba719f5a0458` on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.

Contributor guide

Open the contributing guide

Research direction

Start with std/string/trim.wave at line 61 and review the existing helper assertions in tests/cases/shared/test99.wave. Add coverage for empty, whitespace-only, mixed whitespace, padded, and unpadded inputs, while preserving the individual helper results. Done means trim_range always returns an ordered zero-length range for empty results and satisfies the stated range bounds.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.