An error inside a klammer is reported at your document; the image search path
Assembled from development commit 632297b7657a. Since 1b00738: when something
goes wrong while a klammer is being applied, the report begins with the
line of your document that applied it, then lists the klammers being
applied and where inside the klammer set the fault was raised; the
Python binding's line and column are the application's too. The default
image search path is the document's directory, imgsrc beside it and
../imgsrc, and a not-found report shows exactly those.
This commit is contained in:
1 parent
1b00738654
commit
5c29da52dc
9 files changed
+135
-15
No files matched your search
@@ -248,6 +248,31 @@ else
|
||||
fail "20. exit $hstatus" "$(plain < "$ERRF" | head -2)"
|
||||
fi
|
||||
|
||||
# An error raised INSIDE a klammer's body (here an @eval that divides by
|
||||
# zero) is reported at the application in the user's document -- the
|
||||
# headline -- with the chain of applications and the raising place below
|
||||
# (2026-09-25; before, the headline was the @eval's own line, which for an
|
||||
# SKS klammer is a line of a .k file the user never wrote). Wrap-insensitive
|
||||
# greps: the report is justified to 80 columns.
|
||||
CTX=$(mktemp -d "${TMPDIR:-/tmp}/eval_ctx.XXXXXX")
|
||||
printf '@@bad x : @eval 1/*x* @ @@\n@@outer y : @bad *y* @ @@\ntext\n@bad 0 @\n' > "$CTX/ctx.kt"
|
||||
printf '@@bad x : @eval 1/*x* @ @@\n@@outer y : @bad *y* @ @@\ntext\n@outer 0 @\n' > "$CTX/nested.kt"
|
||||
"$K/bin/ktext" "$CTX/ctx.kt" --klammersets none -d >"$OUTF" 2>"$ERRF"; cstatus=$?
|
||||
ctext=$(tr '\n' ' ' < "$ERRF" | tr -s ' ')
|
||||
if [ $cstatus -ne 0 ] && case "$ctext" in *"ctx.kt, line 4, character 1:"*"applying @bad"*"at "*"ctx.kt, line 1, character "*"ZeroDivisionError"*) true;; *) false;; esac; then
|
||||
pass "21. an error inside a klammer body is headlined at the application, with the chain"
|
||||
else
|
||||
fail "21. exit $cstatus" "$(plain < "$ERRF" | head -6 | tr '\n' '|')"
|
||||
fi
|
||||
"$K/bin/ktext" "$CTX/nested.kt" --klammersets none -d >"$OUTF" 2>"$ERRF"; cstatus=$?
|
||||
ctext=$(tr '\n' ' ' < "$ERRF" | tr -s ' ')
|
||||
if [ $cstatus -ne 0 ] && case "$ctext" in *"nested.kt, line 4, character 1:"*"applying @outer"*"applying @bad at "*"nested.kt, line 2, character "*"at "*"nested.kt, line 1, character "*) true;; *) false;; esac; then
|
||||
pass "22. ... nested applications are listed outermost first, the raising place last"
|
||||
else
|
||||
fail "22. exit $cstatus" "$(plain < "$ERRF" | head -7 | tr '\n' '|')"
|
||||
fi
|
||||
rm -rf "$CTX"
|
||||
|
||||
echo
|
||||
echo "==========="
|
||||
echo "Results: ${PASS} passed, ${FAIL} failed"
|
||||
|
||||
@@ -262,6 +262,20 @@ except kt.Error as e:
|
||||
EOF
|
||||
expect "12. an undefined klammer: Definition_error with kind, line, column, report" 'error Definition_error definition 1 1 True True'
|
||||
|
||||
# An error raised inside a klammer's body is located, for a script, at the
|
||||
# APPLICATION (line 3 here), not at the @eval in the definition (line 1).
|
||||
run <<'EOF'
|
||||
import klammertext as kt
|
||||
M = kt.Machine(klammersets="none")
|
||||
try:
|
||||
M.read("@@bad x : @eval 1/*x* @ @@\ntext\n@bad 0 @")
|
||||
M.apply()
|
||||
print("no error")
|
||||
except kt.Error as e:
|
||||
print("error", e.line, e.column, "applying @bad" in str(e))
|
||||
EOF
|
||||
expect "12a. an error inside a klammer body is located at the application" 'error 3 1 True'
|
||||
|
||||
run <<'EOF'
|
||||
import klammertext as kt
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user