fix: bring back vec1
This commit is contained in:
parent
9d99b509b2
commit
836e853827
|
@ -125,7 +125,8 @@ pub enum TypedExpr {
|
|||
|
||||
If {
|
||||
location: Span,
|
||||
branches: Vec<IfBranch<Self>>,
|
||||
#[serde(with = "Vec1Ref")]
|
||||
branches: Vec1<IfBranch<Self>>,
|
||||
final_else: Box<Self>,
|
||||
tipo: Rc<Type>,
|
||||
},
|
||||
|
@ -180,6 +181,16 @@ pub enum TypedExpr {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[serde(remote = "Vec1")]
|
||||
struct Vec1Ref<T>(#[serde(getter = "Vec1::as_vec")] Vec<T>);
|
||||
|
||||
impl<T> From<Vec1Ref<T>> for Vec1<T> {
|
||||
fn from(v: Vec1Ref<T>) -> Self {
|
||||
Vec1::try_from_vec(v.0).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl TypedExpr {
|
||||
pub fn tipo(&self) -> Rc<Type> {
|
||||
match self {
|
||||
|
@ -289,7 +300,7 @@ impl TypedExpr {
|
|||
| Self::RecordUpdate { location, .. }
|
||||
| Self::CurvePoint { location, .. } => *location,
|
||||
|
||||
Self::If { branches, .. } => branches.first().unwrap().body.type_defining_location(),
|
||||
Self::If { branches, .. } => branches.first().body.type_defining_location(),
|
||||
|
||||
Self::Sequence {
|
||||
expressions,
|
||||
|
|
|
@ -453,7 +453,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
|||
TraceLevel::Silent => Ok(typed_value),
|
||||
TraceLevel::Verbose | TraceLevel::Compact => Ok(TypedExpr::If {
|
||||
location,
|
||||
branches: vec![IfBranch {
|
||||
branches: vec1::vec1![IfBranch {
|
||||
condition: typed_value,
|
||||
body: var_true,
|
||||
location,
|
||||
|
@ -1428,7 +1428,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
|||
|
||||
let tipo = body.tipo();
|
||||
|
||||
let mut typed_branches = vec![TypedIfBranch {
|
||||
let mut typed_branches = vec1::vec1![TypedIfBranch {
|
||||
body,
|
||||
condition,
|
||||
location: first.location,
|
||||
|
|
Loading…
Reference in New Issue