~jojo/effem

62dc666084e2e25cc082617a8207692b8500f7eb — JoJo 3 months ago afdbcfd
fix args not evaluated before app
2 files changed, 5 insertions(+), 1 deletions(-)

M src/cache.rs
M src/eval.rs
M src/cache.rs => src/cache.rs +1 -0
@@ 50,6 50,7 @@ impl Cache {
    }

    pub fn fetch_evaluated_at(&mut self, fundef_query: DefId, args: &[abase::Operand]) -> Result<abase::Operand> {
        debug_assert!(args.iter().all(|arg| !matches!(arg, abase::Operand::Local(_))));
        let _ = self.fetch_evaluated(fundef_query)?;
        match self.abaseds[&fundef_query] {
            abase::GlobDef::FunDef(ref fdef) => eval::eval_fun_at(self, &fdef.clone(), args),

M src/eval.rs => src/eval.rs +4 -1
@@ 61,7 61,10 @@ impl<'c, 'd> EvalDef<'c, 'd> {
                (x_e, y_e) => panic!("ice: cannot apply binary operation {op:?} to {x_e:?} and {y_e:?}"),
            },
            Expr::Call(f, xs) => match self.eval_operand(f)? {
                Global(fid) => self.cache.fetch_evaluated_at(fid, xs),
                Global(fid) => {
                    let xs = xs.iter().map(|x| self.eval_operand(x)).collect::<Result<Vec<_>>>()?;
                    self.cache.fetch_evaluated_at(fid, &xs)
                }
                fe => panic!("ice: applying non-function {fe:?} ({f:?})"),
            },
            Expr::Operand(rand) => self.eval_operand(rand),