---
source: compiler-core/src/type_/tests.rs
expression: "\npub type Vector {\n  Vector2(x: Float, y: Float)\n  Vector3(x: Float, y: Float, z: Float)\n}\n\npub fn increase_y(vector, by increase) {\n  case vector {\n    Vector2(y:, ..) as vector | Vector3(y:, ..) as vector ->\n      Vector2(..vector, y: y +. increase)\n  }\n}\n"
---
----- SOURCE CODE

pub type Vector {
  Vector2(x: Float, y: Float)
  Vector3(x: Float, y: Float, z: Float)
}

pub fn increase_y(vector, by increase) {
  case vector {
    Vector2(y:, ..) as vector | Vector3(y:, ..) as vector ->
      Vector2(..vector, y: y +. increase)
  }
}


----- ERROR
error: Unsafe record update
   ┌─ /src/one/two.gleam:10:17
   │
10 │       Vector2(..vector, y: y +. increase)
   │                 ^^^^^^ I'm not sure this is always a `Vector2`

This value cannot be used to build an updated `Vector2` as it could be some
other variant.

Consider pattern matching on it with a case expression and then
constructing a new record with its values.
