Skip to content

Invalid LHS Of Assignment #2391

@MahadMuhammad

Description

@MahadMuhammad


I tried code:

#![allow(unused)]
const SOME_CONST: i32 = 12;

fn some_function() {
    SOME_CONST = 15; // error: a constant value cannot be changed!

}

fn main(){
    some_function();
}

I expected to see this happen:

  • Emit error message, similiar to rustc .i.e.,
    • invalid left-hand side of assignment
  • Error message emitted by rustc:
error[E0070]: invalid left-hand side of assignment
 --> <source>:6:16
  |
6 |     SOME_CONST = 15; // error: a constant value cannot be changed!
  |     ---------- ^
  |     |
  |     cannot assign to this expression

error: aborting due to previous error

For more information about this error, try `rustc --explain E0070`.
Compiler returned: 1

Instead, this happened:

  • COmpiled Successfully.
  • This is the output of gccrs:
Compiler returned: 0

Meta

  • What version of Rust GCC were you using, git sha b9566fd.
  • gccrs (Compiler-Explorer-Build-gcc-2f91d511200bf85558c9013b09a458c06edd1e02-binutils-2.40) 13.0.1 20230417 (experimental)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions