E4093

E4093#

该类型不是记录类型。

当您尝试使用 T::{ .. } 语法构造不是结构体的类型时会发生此错误。

错误示例#

///|
priv enum Point {
  D2(Double, Double)
  D3(Double, Double, Double)
}

///|
test {
  let a = Point::{ x: 1.0, y: 2.0 }
  //      ^~~~~
  // Error: The type Point is not a struct type
  ignore(a)
}

建议#

您应该使用正确的语法来构造类型。

///|
priv enum Point {
  D2(Double, Double)
  D3(Double, Double, Double)
}

///|
test {
  let a = Point::D2(1.0, 2.0)
  let b = Point::D3(1.0, 2.0, 3.0)
  match a {
    D2(x, y) => {
      inspect(x, content="1")
      inspect(y, content="2")
    }
    D3(_, _, _) => fail("unexpected 3D point")
  }
  match b {
    D2(_, _) => fail("unexpected 2D point")
    D3(x, y, z) => {
      inspect(x, content="1")
      inspect(y, content="2")
      inspect(z, content="3")
    }
  }
}