aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar René Kijewski <rene.kijewski@fu-berlin.de>2023-07-31 20:58:23 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 21:29:35 +0200
commit985eb8955f36e909d18f7ea6eaf4c748e7afd17a (patch)
tree01aca3e735d2c5c698495ce0b3a383911f2563f5 /testing
parent107bdfdd7658919691948f629adf2254cd6aa367 (diff)
downloadaskama-985eb8955f36e909d18f7ea6eaf4c748e7afd17a.tar.gz
askama-985eb8955f36e909d18f7ea6eaf4c748e7afd17a.tar.bz2
askama-985eb8955f36e909d18f7ea6eaf4c748e7afd17a.zip
Fix parsing arrays
This change * allows using empty arrays `[]` in expessions, * adds a cut when the leading `[` was encountered, and * fixes the interaction between arrays and boolean OR. IMO the restriction that you couldn't use empty arrays is not needed. The missing cut made error messages slictly worse if you forget to add the closing `]`. Filter expressions must not have white spaces before the pipe `|`. The white space is used to tell a filter expressions, and `std::ops::Or` apart.
Diffstat (limited to 'testing')
-rw-r--r--testing/tests/ui/loop_cycle_empty.rs3
-rw-r--r--testing/tests/ui/loop_cycle_empty.stderr7
2 files changed, 3 insertions, 7 deletions
diff --git a/testing/tests/ui/loop_cycle_empty.rs b/testing/tests/ui/loop_cycle_empty.rs
index 4aa6010..30d54fa 100644
--- a/testing/tests/ui/loop_cycle_empty.rs
+++ b/testing/tests/ui/loop_cycle_empty.rs
@@ -1,6 +1,3 @@
-// Nb. this test fails because currently an empty array "[]" is always a syntax error in askama,
-// but even if this changes, this test should keep failing, but possibly with another error message
-
use askama::Template;
#[derive(Template)]
diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr
index 4fc35bb..dd4f0dd 100644
--- a/testing/tests/ui/loop_cycle_empty.stderr
+++ b/testing/tests/ui/loop_cycle_empty.stderr
@@ -1,8 +1,7 @@
-error: problems parsing template source at row 1, column 35 near:
- "[]) }}{{ v }},{% endfor %}"
- --> tests/ui/loop_cycle_empty.rs:6:10
+error: loop.cycle(…) cannot use an empty array
+ --> tests/ui/loop_cycle_empty.rs:3:10
|
-6 | #[derive(Template)]
+3 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)