summaryrefslogtreecommitdiff
path: root/src/eval/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-26 13:49:04 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-26 13:49:04 +0100
commit16ac3f3ebc49c5a6e3f61d8546f2f187b191c346 (patch)
tree7b66f108f23c64614a507e2815f706ceb72df157 /src/eval/mod.rs
parentac788f2082711161ec8208eede04d9a2bae02241 (diff)
Small improvements ♻
Diffstat (limited to 'src/eval/mod.rs')
-rw-r--r--src/eval/mod.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index c604f2d0..8563520e 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -270,8 +270,8 @@ impl Spanned<&ExprBinary> {
// Short-circuit boolean operations.
match (self.v.op.v, &lhs) {
- (BinOp::And, Value::Bool(false)) => return Value::Bool(false),
- (BinOp::Or, Value::Bool(true)) => return Value::Bool(true),
+ (BinOp::And, Value::Bool(false)) => return lhs,
+ (BinOp::Or, Value::Bool(true)) => return lhs,
_ => {}
}
@@ -310,12 +310,10 @@ impl Spanned<&ExprBinary> {
let lhs = std::mem::replace(slot, Value::None);
*slot = op(lhs, rhs);
return Value::None;
+ } else if ctx.scopes.is_const(id) {
+ ctx.diag(error!(span, "cannot assign to constant"));
} else {
- if ctx.scopes.is_const(id) {
- ctx.diag(error!(span, "cannot assign to constant"));
- } else {
- ctx.diag(error!(span, "unknown variable"));
- }
+ ctx.diag(error!(span, "unknown variable"));
}
} else {
ctx.diag(error!(span, "cannot assign to this expression"));