Improve error handling for continue and break
Open
Nobody has claimed this yet.
diagnostic
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
Tried this test case: https://github.com/rust-lang/rust/blob/aa3ca1994904f2e056679fce1f185db8c7ed2703/src/test/ui/closure-array-break-length.rs
#[lang = "fn_once"]
pub trait FnOnce<Args> {
#[lang = "fn_once_output"]
type Output;
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}
fn main() {
|_: [_; continue]| {}; //~ ERROR: `continue` outside of loop
while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of loop
while |_: [_; break]| {} {} //~ ERROR: `break` outside of loop
}
We return: https://godbolt.org/z/Ko7o4r5ac
<source>:10:13: error: cannot 'continue' outside of a loop
10 | |_: [_; continue]| {}; //~ ERROR: `continue` outside of loop
| ^~~~~~~~
<source>:10:13: error: failed to type resolve expression
<source>:12:19: error: expected 'usize' got '!'
12 | while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of loop
| ^~~~~~~~
<source>:14:19: error: expected 'usize' got '!'
14 | while |_: [_; break]| {} {} //~ ERROR: `break` outside of loop
| ^~~~~
Compiler returned: 1
Contributor guide
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.
Research direction
Start with the referenced test case in src/test/ui/closure-array-break-length.rs and reproduce it in gccrs. Compare the diagnostics for continue and break used in array lengths with the expected errors, ensuring the spurious type-resolution and type-mismatch errors are not emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100