summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/function.rs4
-rw-r--r--src/eval/mod.rs4
-rw-r--r--src/eval/ops.rs18
3 files changed, 15 insertions, 11 deletions
diff --git a/src/eval/function.rs b/src/eval/function.rs
index c83d8b2b..931a90a0 100644
--- a/src/eval/function.rs
+++ b/src/eval/function.rs
@@ -226,7 +226,3 @@ impl Debug for Arg {
Debug::fmt(&self.value.v, f)
}
}
-
-dynamic! {
- Args: "arguments",
-}
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 6b28e5ab..a0c31e98 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -494,6 +494,10 @@ impl Eval for ClosureExpr {
// Put the remaining arguments into the sink.
if let Some(sink) = &sink {
+ dynamic! {
+ Args: "arguments",
+ }
+
ctx.scopes.def_mut(sink, args.take());
}
diff --git a/src/eval/ops.rs b/src/eval/ops.rs
index 6fac354d..ede1230f 100644
--- a/src/eval/ops.rs
+++ b/src/eval/ops.rs
@@ -3,7 +3,7 @@ use std::convert::TryFrom;
use super::{Dynamic, Value};
use crate::diag::StrResult;
-use crate::geom::{Align, Get, Spec};
+use crate::geom::{Align, Spec, SpecAxis};
use crate::util::EcoString;
use Value::*;
@@ -94,14 +94,18 @@ pub fn add(lhs: Value, rhs: Value) -> StrResult<Value> {
if let (Some(&a), Some(&b)) =
(a.downcast::<Align>(), b.downcast::<Align>())
{
- if a.axis() == b.axis() {
- return Err(format!("cannot add two {:?} alignments", a.axis()));
+ dynamic! {
+ Spec<Align>: "2d alignment",
}
- let mut aligns = Spec::default();
- aligns.set(a.axis(), Some(a));
- aligns.set(b.axis(), Some(b));
- return Ok(Dyn(Dynamic::new(aligns)));
+ return if a.axis() != b.axis() {
+ Ok(Dyn(Dynamic::new(match a.axis() {
+ SpecAxis::Horizontal => Spec { x: a, y: b },
+ SpecAxis::Vertical => Spec { x: b, y: a },
+ })))
+ } else {
+ Err(format!("cannot add two {:?} alignments", a.axis()))
+ };
}
}