Skip to content

Commit

Permalink
Add tests for eval and typed eval
Browse files Browse the repository at this point in the history
  • Loading branch information
twright committed Nov 7, 2024
1 parent 69dfee6 commit 57f7c5d
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 484 deletions.
13 changes: 12 additions & 1 deletion src/type_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,18 @@ impl TypeCheckableHelper<SExprTE> for SExpr<VarName> {
(inner.deref(), *idx, default).type_check_raw(ctx, errs)
}
SExpr::Var(id) => id.type_check_raw(ctx, errs),
SExpr::Eval(_) => todo!("Implement support for Eval (to be renamed)"),
SExpr::Eval(e) => {
let e_check = e.type_check_raw(ctx, errs)?;
match e_check {
SExprTE::Str(e_str) => Ok(SExprTE::Str(SExprStr::Eval(Box::new(e_str)))),
_ => {
errs.push(SemanticError::TypeError(
"Eval can only be applied to string expressions".into(),
));
Err(())
}
}
}
SExpr::Defer(_) => todo!("Implement support for Defer"),
SExpr::Update(_, _) => todo!("Implement support for Update"),
}
Expand Down
Loading

0 comments on commit 57f7c5d

Please sign in to comment.