fix: [x; _] bug

This commit is contained in:
Shunsuke Shibayama 2023-10-02 22:50:17 +09:00
parent cce95e7210
commit 24da5cdfbd
4 changed files with 30 additions and 0 deletions

View file

@ -1809,6 +1809,10 @@ impl Context {
}
Ok(array_t(union, TyParam::value(len)))
}
TyParam::UnsizedArray(elem) => {
let elem = self.convert_tp_into_type(*elem)?;
Ok(unknown_len_array_t(elem))
}
TyParam::Set(tps) => {
let mut union = Type::Never;
for tp in tps.iter() {
@ -1874,6 +1878,10 @@ impl Context {
}
Ok(ValueObj::Array(new.into()))
}
TyParam::UnsizedArray(elem) => {
let elem = self.convert_tp_into_value(*elem)?;
Ok(ValueObj::UnsizedArray(Box::new(elem)))
}
TyParam::Tuple(tys) => {
let mut new = vec![];
for elem in tys {
@ -1978,6 +1986,13 @@ impl Context {
}
Ok(TyParam::Array(new_arr))
}
ValueObj::UnsizedArray(elem) => {
let tp = match Self::convert_value_into_tp(*elem) {
Ok(tp) => tp,
Err(tp) => tp,
};
Ok(TyParam::UnsizedArray(Box::new(tp)))
}
ValueObj::Tuple(vs) => {
let mut new_ts = vec![];
for v in vs.iter().cloned() {