Skip to content

gccrs does not check if something is assignable #3287

@liushuyu

Description

@liushuyu

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

fa93e28

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticdiagnostic static analysis

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions