Compiler error message is unhelpful when trying `ndarray::s!([2..3])`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with the ndarray::s! macro and the failing call shown at src/tiler.rs:59. Reproduce the compiler diagnostic for ndarray::s!([2..3]), then inspect the macro documentation and determine whether the finished change should provide a clearer diagnostic or explain the nested-bracket mistake in the documentation.
Written by the indexing model from the issue text.
Description
error[E0277]: the trait bound `[std::ops::Range<{integer}>; 1]: ndarray::SliceNextDim` is not satisfied
--> src/tiler.rs:59:25
|
59 | input.slice(ndarray::s!([2..3]));
| ^^^^^^^^^^^^^^^^^^^ the trait `ndarray::SliceNextDim` is not implemented for `[std::ops::Range<{integer}>; 1]`
|
note: required by a bound in `ndarray::SliceNextDim::next_in_dim`
I type () after function-like macro call (that is not constructing a data structure sample) almost automatically and I also remember that I need array of ranges for ndarray::s!. That has resulted in s!([...]) twice already, and I spend more than a minute looking at the code, documentation and error message.
The error message looks as if arrays or ranges are not OK for ndarray::s. It is not obvious that the mistake is not in usage of ranges or arrays, but in usage of extra outer parentheses.. Although one should not use arrays when doing ndarray:s, square brackets in documentation makes it feels as if we were specifying a Rust array as input to the macro, which may result in actual Rust array being fed to it.
Maybe the macro should detect extra brackets and output more more helpful warning or error? Or at least documentation of ndarray::s should mention possible compiler error about []: SliceNextDim and tell user to look at nested brackets?
- Dominant language
- Rust
- Stars
- 4.3k
- Forks
- 391
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-ndarray/ndarray
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-ndarray/ndarray#1612 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-ndarray/ndarray#1617 · 1 comment ·
-
bug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 68/100
rust-ndarray/ndarray#1615 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-ndarray/ndarray#1610 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
rust-ndarray/ndarray#1609 ·
All issues in rust-ndarray/ndarray
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100