Troubleshooting
Texl never stops with an error. When something goes wrong, the output shows it in one of the ways below.
The output contains [[Undefined]]
An operation in the tag was invalid. Find out which one by inspecting the
value with undef.inspect. Its
description says what went wrong in plain words:
<% e = undef.inspect ("Total" + 10) %><% e.description %>
cannot add the text `"Total"` and the number `10`
Here the sum of a text and a number is invalid. The fix is
"Total" + text.from 10.
pos tells where the error is, counted in bytes from the start of the
document, and uri tells which document it is in. An error made by a built-in
function points to its call.
A tag with a syntax error cannot inspect itself. A stray bracket or an unknown
character makes the whole tag [[Undefined]], and none of it runs, so the names
it binds stay unbound. To read the error, give the code to parse in another
tag:
<% e = undef.inspect (parse "(2 + 3)) * 4" {}) %><% e.description %>
unexpected `)`
The most common causes are:
- mixing types:
"Total: " + 10, or a number given to a text function; - a missing argument, which makes it
Nothing:add 3instead ofadd (3, 4); - calling the wrong value:
f g xinstead off (g x)(see pitfalls); - a syntax error, such as a missing or extra bracket, or a single-quoted text;
- a document that cannot be loaded: a wrong address in
texl.import(see Missing documents).
A value is missing
If a tag writes nothing where you expected a value:
- Check the spelling. A misspelled name is
Nothing, andNothingwrites nothing. - Check that the name is bound before the tag. Tags run in order, and a name bound in a later tag is not yet available.
- Check the host's globals. Is the data you expect actually passed to the template?
- Check
?conditions.cond ? valuewrites nothing when the condition is false.
Give optional names a default to make missing values visible:
<% customer.name ; "MISSING NAME" %>.
The output contains [[List of N]], [[Namespace of N]] or [[Func]]
The tag's value is a list, a namespace or a function, which have no text form.
- For a list, write its items:
list.enum items, ortext.join ", " (list.enum items). - For a namespace, pick a member:
customer.name. - For a function, you probably forgot to call it:
today ()instead oftoday.
The output contains [[Pending Promise]]
A promise inside a tuple, or inside another value, was not ready when the tag was written. Only a promise returned by the tag itself is awaited. See Several promises.
Values are separated by commas
The tag's value is a tuple, which is written as its items separated by , .
Often this is a sequence of steps whose intermediate values are not Nothing:
use = rather than : for the intermediate steps. To join items with another
separator, use text.join.
Unexpected empty lines
A tag alone on its line leaves the line break behind. See Line breaks around tags.
"recursion too deep"
A recursive function never reaches the case that stops it, or it calls itself more than a few hundred times. Check that the condition that ends the recursion is reached for every input. See Evaluation order and Recursion.
Part of the template is copied as it is
A <% without a matching %> makes the rest of the template plain text. A
%> inside a text literal ends the tag early. See
Writing the delimiters as text.