summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/compute/construct.rs3
-rw-r--r--tests/typ/compute/construct.typ4
2 files changed, 7 insertions, 0 deletions
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs
index a30faf2e..04195f42 100644
--- a/library/src/compute/construct.rs
+++ b/library/src/compute/construct.rs
@@ -258,6 +258,9 @@ pub fn symbol(
variants: Vec<Spanned<Variant>>,
) -> Value {
let mut list = Vec::new();
+ if variants.is_empty() {
+ bail!(args.span, "expected at least one variant");
+ }
for Spanned { v, span } in variants {
if list.iter().any(|(prev, _)| &v.0 == prev) {
bail!(span, "duplicate variant");
diff --git a/tests/typ/compute/construct.typ b/tests/typ/compute/construct.typ
index dc146719..ee0a24b0 100644
--- a/tests/typ/compute/construct.typ
+++ b/tests/typ/compute/construct.typ
@@ -58,6 +58,10 @@
#envelope.fly
---
+// Error: 8-10 expected at least one variant
+#symbol()
+
+---
// Test conversion to string.
#test(str(123), "123")
#test(str(50.14), "50.14")