Brad Arant 97142ce9b4 Fix substring(str, start) - the 2-argument form was completely broken
Found while writing a new Expressions Reference chapter for the manual,
where every function got run for real before being documented rather
than trusted from reading the source alone - substring('helloworld', 7)
threw "operand is not valid." immediately after producing the correct
answer, confirmed via debug tracing showing an extra Operand constructed
on empty input right after the 2-arg case finished.

Root cause: a missing pair of braces around the 3-argument-only branch
meant Operand parm3(in, tag) and its own closing-paren check ran
unconditionally, even after the 2-arg form's own "if(in.ifNext(')'))"
check had already matched and produced string = parm1.string.substring(
parm2.string.asInteger()) - so it immediately tried to parse a third
argument from whatever was left (nothing, since the real closing paren
was already consumed), and construction on empty input always throws.
The 3-argument form (substring(str, start, length)) was unaffected,
since its own path never hit the first if-branch's early exit.

Fixed by properly scoping the 3-arg branch inside an else, so it only
runs when the 2-arg form's own closing paren wasn't found. Verified both
forms with real jet-2.0 runs: substring('helloworld', 7) -> "rld",
substring('helloworld', 0, 5) -> "hello".
2026-08-26 10:39:38 -07:00
2024-12-02 15:46:49 -08:00
2025-05-06 07:33:04 -07:00
2025-05-06 07:33:04 -07:00
2025-01-09 07:49:11 -08:00
2025-02-07 19:29:18 -08:00
2025-02-07 19:29:18 -08:00
2025-12-09 12:29:39 -08:00
2025-01-09 08:02:38 -08:00
2025-01-09 08:02:38 -08:00
2025-02-07 16:10:13 -08:00
2025-11-21 19:15:48 -08:00
2025-11-21 19:15:48 -08:00
2025-12-04 17:05:57 -08:00
2025-05-06 07:33:04 -07:00
2025-11-21 19:15:48 -08:00
2025-11-21 19:15:48 -08:00
2025-11-21 19:15:48 -08:00
2025-11-21 19:15:48 -08:00
2025-11-21 19:15:48 -08:00
2025-11-21 19:15:48 -08:00
S
Description
JET 2.0 core library.
40 MiB
0 Stars 0 Watchers 0 Forks
Languages
HTML 50.2%
TeX 18.7%
C++ 15%
JavaScript 7.5%
CSS 4.4%
Other 4.2%