gccrs does not check if something is assignable
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
Summary
gccrs does not check if something is assignable, and gccrs accepts many un-assignable expressions.
Reproducer
I tried this code:
fn main() -> i32 {
let mut x = 42;
x + 1 = 2;
x
}
Does the code make use of any (1.49) nightly feature ?
- Nightly
Godbolt link
No response
Actual behavior
The current behavior is that gccrs accepts this kind of semantically invalid code and even successfully generates machine code for them (in this case, gccrs generates code to make the function return 42).
Expected behavior
I expected to see an error thrown like rustc does:
error[E0070]: invalid left-hand side of assignment
--> test1.rs:3:11
|
3 | x + 1 = 2;
| ----- ^
| |
| cannot assign to this expression
GCC Version
fa93e280ed1c11d9775cb9c3211e13853d39c51c
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 by compiling the reproducer with gccrs and compare its result with rustc's E0070 diagnostic for x + 1 = 2. Trace the assignment semantic-checking entry point responsible for accepting the expression; done means gccrs rejects unassignable left-hand sides and reports an appropriate error without generating machine code.
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