foresterre / foresterre/parameterized

Attribute argument / function parameter amount mismatch: improve error message

Open
#12 0 comments 0 reactions 0 assignees View on GitHub
A-ui C-enhancement
Dominant language
Rust
Stars
27
Forks
2
PR merge metrics
No merged PRs in 30d

Description

The following code will obvisouly fail, since our function has two inputs, but in our attribute, we only provide one.
```
#[parameterized(input = {
&["03579", "0", "1", "1"]
})]
fn should_fail(input: &[&str], expected: (u32, u32, u32, u32)) {
let some: (u32, u32, u32, u32) = ParseInputsFromIter::parse(input).unwrap();
assert_eq!(some, expected);
}

```

it does fail (which is good), but the error states "this should never happen", while it can and isn't an `unreachable` error case.
```
#[parameterized(input = {
&["03579", "0", "1", "1"]
})]
fn should_fail(input: &[&str], expected: (u32, u32, u32, u32)) {
let some: (u32, u32, u32, u32) = ParseInputsFromIter::parse(input).unwrap();
assert_eq!(some, expected);
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in the parameterized attribute handling that checks the number of supplied arguments against the function parameters, and search for the "this should never happen" message. Update the failure wording for this mismatch and add or adjust a regression test covering the shown one-argument, two-parameter case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.