yeah, if you code on 20 years old compilers with no warnings. GCC 4.1 warns about this (with -Wall) and Clang 3.4 warns about this too, without any warning flag.
"Shooting yourself in the foot is your fault for not using a linter that detects accidental misuse of assignment!"
Imagine you have a sealed class Foo, with `class Bar(x: String) : Foo()` and `Baz() : Foo()`.
Now, imagine you have a method, returning an object of type Foo: `fun foo(): Foo`
And you want to pattern match on the result of this method:
  when(foo()) {
      is Bar -> ...
      is Baz -> ...
  }
Now imagine Kotlin had that feature; then we could just do the following:
  when(foo = foo()) {
    is Bar -> foo.x
    is Baz -> ...
  }What I'm thinking of here is Rust's match statements, which do give you the ability to make use of those intermediary values by making use of Rust's enum type.
https://doc.rust-lang.org/book/second-edition/ch06-02-match....