aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-08 00:15:46 +0100
committerGustav Sörnäs <gustav@sornas.net>2021-03-08 00:16:13 +0100
commit8e2c0e345facee83d63991dda548b71e6a0c4cf6 (patch)
tree86ead8f6a3329ff1999af49570c44df50ecf7461
parentdc25e664305ed49edff4e45eaec6ed1fad910c60 (diff)
downloadsylt-8e2c0e345facee83d63991dda548b71e6a0c4cf6.tar.gz
error on '(,)'-tuples
Currently creats a lot of syntax errors. See #100.
-rw-r--r--progs/tests/tuples_fail_invalid_singleton.sy7
-rw-r--r--src/compiler.rs8
2 files changed, 15 insertions, 0 deletions
diff --git a/progs/tests/tuples_fail_invalid_singleton.sy b/progs/tests/tuples_fail_invalid_singleton.sy
new file mode 100644
index 0000000..c70fc21
--- /dev/null
+++ b/progs/tests/tuples_fail_invalid_singleton.sy
@@ -0,0 +1,7 @@
+start :: fn {
+ a := (,)
+ a
+}
+
+//TODO(gu) See #100
+// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _)]
diff --git a/src/compiler.rs b/src/compiler.rs
index 46fe38c..c4f687f 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -691,6 +691,14 @@ impl Compiler {
Token::Newline => {
self.eat();
}
+ Token::Comma => {
+ //TODO(gu): This creates a lot of syntax errors since the compiler panic is
+ // ignored and the statement is tried as a grouping instead, even though we
+ // _know_ that this can't be parsed as a grouping either.
+ // Tracked in #100.
+ error!(self, "Tuples must begin with an element or ')'.");
+ return;
+ }
_ => {
self.expression(block);
num_args += 1;