chore: fmt

This commit is contained in:
2025-05-10 20:13:00 +08:00
parent 046b03c60e
commit d04d46c905
7 changed files with 49 additions and 53 deletions

View File

@@ -2,17 +2,17 @@ use ecow::EcoString;
use itertools::Itertools;
use rpds::HashTrieMap;
use crate::bytecode::{OpCodes, ThunkIdx};
use crate::bytecode::OpCodes;
use crate::error::Result;
use crate::ir;
use crate::ty::internal::Value;
use crate::vm::{CapturedEnv, VM};
use crate::ir;
#[derive(Debug, Clone)]
pub enum Param {
Ident(EcoString),
Formals {
formals: Vec<(EcoString, Option<ThunkIdx>)>,
formals: Vec<(EcoString, Option<usize>)>,
ellipsis: bool,
alias: Option<EcoString>,
},
@@ -22,8 +22,18 @@ impl From<ir::Param> for Param {
fn from(value: ir::Param) -> Self {
match value {
ir::Param::Ident(ident) => Param::Ident(ident),
ir::Param::Formals { formals, ellipsis, alias } =>
Param::Formals { formals: formals.into_iter().map(|(sym, default)| (sym, default.map(|default| default.idx))).collect(), ellipsis, alias }
ir::Param::Formals {
formals,
ellipsis,
alias,
} => Param::Formals {
formals: formals
.into_iter()
.map(|(sym, default)| (sym, default.map(|default| default.idx)))
.collect(),
ellipsis,
alias,
},
}
}
}
@@ -32,7 +42,7 @@ impl From<ir::Param> for Param {
pub struct Func {
pub env: Option<CapturedEnv>,
pub param: Param,
pub opcodes: OpCodes
pub opcodes: OpCodes,
}
impl Func {

View File

@@ -362,18 +362,14 @@ impl Value {
pub fn select(&mut self, sym: Symbol) -> &mut Self {
if let Value::AttrSet(attrs) = self {
let val = attrs
.select(sym.clone())
.unwrap_or_else(|| Value::Catchable(c::Catchable::new(Some(format!(
"{sym:?} not found"
)))));
let val = attrs.select(sym.clone()).unwrap_or_else(|| {
Value::Catchable(c::Catchable::new(Some(format!("{sym:?} not found"))))
});
*self = val;
} else if let Value::RecAttrSet(attrs) = self {
let val = attrs
.select(sym.clone())
.unwrap_or_else(|| Value::Catchable(c::Catchable::new(Some(format!(
"{sym:?} not found"
)))));
let val = attrs.select(sym.clone()).unwrap_or_else(|| {
Value::Catchable(c::Catchable::new(Some(format!("{sym:?} not found"))))
});
*self = val;
} else {
*self = Value::Catchable(Catchable::new(Some(format!(