-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Ranges and str substring are inconsistent (off by 1) #7761
Copy link
Copy link
Closed
Labels
category:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedBehavior between different commands or types inconsistent/unexpected
Milestone
Description
Describe the bug
1..3 produces 3 numbers:
〉1..3
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
╰───┴───╯str substring 1..3 produces 2 characters:
〉"abcdefg" | str substring 1..3
bcThat's an unpleasant inconsistency.
How to reproduce
Use str substring with a range, observe that it produces 1 fewer character than there are numbers in the range.
Expected behavior
I expect that a range with n numbers should produce a string of n characters when used with str substring.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.74.1 |
| branch | main |
| commit_hash | b004aac |
| build_os | windows-x86_64 |
| build_target | x86_64-pc-windows-msvc |
| rust_version | rustc 1.65.0 (897e37553 2022-11-02) |
| rust_channel | 1.65.0-x86_64-pc-windows-msvc |
| cargo_version | cargo 1.65.0 (4bc8f24d3 2022-10-20) |
| pkg_version | 0.74.1 |
| build_time | 2023-01-12 12:55:53 -08:00 |
| build_rust_channel | release |
| features | database, default, trash, which, zip |
| installed_plugins |
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
category:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedBehavior between different commands or types inconsistent/unexpected