Rust-GCC / Rust-GCC/gccrs

Bad error handling on wildcard pattern within expression

Open
#867 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good-first-pr
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

I tried this code:

fn test() {
    let _ = 42;
    let a = _ + 123;
}

I expected to see this happen:

error: expected expression, found reserved identifier `_`
 --> test.rs:3:13
  |
3 |     let a = _ + 123;
  |             ^ expected expression

Instead, this happened:

test.rs:3:13: error: found unexpected token ‘_’ in null denotation
    3 |     let a = _ + 123;
      |             ^
test.rs:3:15: error: failed to parse expression in let statement
    3 |     let a = _ + 123;
      |               ^
test.rs:3:5: error: failed to parse statement or expression without block in block expression
    3 |     let a = _ + 123;
      |     ^
test.rs:4:1: error: unrecognised token ‘}’ for start of item
    4 | }
      | ^
test.rs:4:1: error: failed to parse item in crate
test.rs:4:1: error: attempted to get string for ‘}’, which has no string. returning empty string instead

Meta
  • What version of Rust GCC were you using, git sha if possible. 69f6be3ee483c9895b4b5187a44b3e1c8be2ba63

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Rust snippet from the issue and trace how the parser handles _ in expression position and reports the resulting errors. Done means the invalid wildcard expression produces the expected primary diagnostic without the cascade of follow-on errors shown here.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.