Skip to content
Snippets Groups Projects
Commit f9ca9a19 authored by Jasper Gräflich's avatar Jasper Gräflich
Browse files

Appease clippy

parent ff0448ca
No related branches found
No related tags found
No related merge requests found
......@@ -20,12 +20,9 @@ fn eval_ctx(ast: Node, ctx: &mut HashMap<String, Value>) -> Result<Value> {
ctx.insert(ident.clone(), value);
Value::Unit
}
crate::Node::Ident(ident) => ctx
.get(&ident)
.ok_or(Error::Eval(format!(
"Ident error: `{ident}` is not defined"
)))?
.clone(),
crate::Node::Ident(ident) => *ctx.get(&ident).ok_or(Error::Eval(format!(
"Ident error: `{ident}` is not defined"
)))?,
})
}
......
......@@ -27,7 +27,7 @@ pub enum Node {
}
/// `λ_UR` value, result of a computation.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Value {
Num(u32),
Unit,
......
......@@ -13,7 +13,7 @@ fn typecheck_ctx(ast: &Node, ctx: &mut HashMap<String, Type>) -> Result<Type> {
// because a Seq contains at least one element
.try_fold(Type::Diverging, |_, n| typecheck_ctx(n, ctx))?,
Node::Let { ident, expr, ty } => {
let expr_ty = typecheck_ctx(&expr, ctx)?;
let expr_ty = typecheck_ctx(expr, ctx)?;
// If we have some type annotation, it may not be different from the type of `expr`
if let Some(true) = ty.map(|ty| ty != expr_ty) {
return Err(Error::Type(format!(
......@@ -27,10 +27,9 @@ fn typecheck_ctx(ast: &Node, ctx: &mut HashMap<String, Type>) -> Result<Type> {
))))?;
Type::Unit
}
Node::Ident(ident) => ctx
Node::Ident(ident) => *ctx
.get(ident)
.ok_or(Error::Name(format!("`{ident}` is not defined")))?
.clone(),
.ok_or(Error::Name(format!("`{ident}` is not defined")))?,
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment