From 1ee1d078e2480ddd08d40915bc7a74a8352acff0 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 30 Jul 2021 18:04:08 +0200 Subject: Fatal errors - Makes errors fatal, so that a phase is only reached when all previous phases were error-free - Parsing still recovers and can produce multiple errors - Evaluation fails fast and can thus produce only a single error (except for parse errors due to an import) - The single error that could occur during execution is removed for now - Removes Value::Error variant --- tests/typ/code/ops-invalid.typ | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'tests/typ/code/ops-invalid.typ') diff --git a/tests/typ/code/ops-invalid.typ b/tests/typ/code/ops-invalid.typ index 149a60dd..5e56ff98 100644 --- a/tests/typ/code/ops-invalid.typ +++ b/tests/typ/code/ops-invalid.typ @@ -1,67 +1,84 @@ -// Test invalid expressions. +// Test invalid operations. // Ref: false --- -// Missing expressions. - // Error: 3 expected expression {-} +--- // Error: 10 expected expression #test({1+}, 1) +--- // Error: 10 expected expression #test({2*}, 2) --- -// Mismatched types. - // Error: 2-12 cannot apply '+' to template {+([] + [])} +--- // Error: 2-5 cannot apply '-' to string {-""} +--- // Error: 2-8 cannot apply 'not' to array {not ()} +--- // Error: 2-12 cannot apply '<=' to relative and relative {30% <= 40%} +--- // Special messages for +, -, * and /. // Error: 03-10 cannot add integer and string +{(1 + "2", 40% - 1)} + +--- // Error: 12-19 cannot subtract integer from relative -// Error: 21-29 cannot multiply integer with boolean -// Error: 31-39 cannot divide integer by length -{(1 + "2", 40% - 1, 2 * true, 3 / 12pt)} +{(1234567, 40% - 1)} + +--- +// Error: 2-10 cannot multiply integer with boolean +{2 * true} -// Error: 14-22 cannot apply '+=' to integer and string +--- +// Error: 2-10 cannot divide integer by length +{3 / 12pt} + +--- +// Error: 14-22 cannot add integer and string { let x = 1; x += "2" } +--- // Error: 13-14 expected argument list, found integer { test with 2 } +--- // Error: 3-4 expected function, found integer { 1 with () } +--- // Error: 3-10 cannot apply '..' to integer and string { 1 .. "" } --- -// Bad left-hand sides of assignment. - // Error: 3-6 cannot assign to this expression { (x) = "" } +--- // Error: 3-8 cannot assign to this expression { 1 + 2 += 3 } +--- // Error: 3-4 unknown variable { z = 1 } +--- // Error: 3-7 cannot assign to a constant { rect = "hi" } +--- // Works if we define rect beforehand // (since then it doesn't resolve to the standard library version anymore). #let rect = "" -- cgit v1.2.3