jinja: a dotted integer is an index, as in jinja2 -- llama.cpp's #28817

jinja2 reads `obj.0` as `obj[0]`; the engine threw "Static member property must be an
identifier". GLM-5's template tests a tool result with `m.content.0.type`, and the capability
probe swallows the throw, so the template came back as tools=0 tool_calls=0 and every request
with `tools` was refused.

The fix is llama.cpp's ae9afff8, which landed after the lifted commit, taken as it is so the next
refresh drops it. vendor/patches/0021, vendor/UPSTREAM; chat_test
(a_dotted_integer_is_an_index_as_in_jinja2) fails without it on both counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 15:27:18 +02:00
1 parent da1ffff9a8
commit a14fab2317
4 files changed
+60

No files matched your search

+10
View File
@@ -64,6 +64,7 @@ vendor/llama/common/jinja/ <- llama.cpp common/jinja/
llama.h, no common.h -- which is why it lifts cleanly and chat.cpp did not.
LOCAL CHANGES: patches/0015-jinja-print-a-list-or-a-dict-as-its-repr.patch
patches/0021-jinja-a-dotted-integer-is-an-index.patch
vendor/llama/common/chat.{h,cpp}
vendor/llama/common/chat-auto-parser.h
@@ -554,3 +555,12 @@ PATCH SERIES
\u form of a character it leaves out (\u0009 for \t), and a positive class admits \t \n
\r \f \b only in their short form. gbnf_test covers each escape in and out of a class, quantified, and negated, and the
refusals.
patches/0021-jinja-a-dotted-integer-is-an-index.patch
llama.cpp's ae9afff8 ("jinja : support dot property integer literals (#28817)"), after the
lifted commit; drop it on the next refresh. jinja2 reads `obj.0` as `obj[0]`; the engine
threw "Static member property must be an identifier". GLM-5's template tests a tool result
with `m.content.0.type`, and since the probe swallows the throw the template came back as
tools=0 tool_calls=0, as 0006 describes: every request with `tools` was refused.
tests/chat_test.cpp (a_dotted_integer_is_an_index_as_in_jinja2).
+6
View File
@@ -779,6 +779,12 @@ value member_expression::execute_impl(context & ctx) {
} else {
property = this->property->execute(ctx);
}
} else if (is_stmt<integer_literal>(this->property)) {
// syntax: obj.index
property = mk_val<value_int>(cast_stmt<integer_literal>(this->property)->val);
if (property->as_int() < 0) {
throw std::runtime_error("Static member property cannot be negative");
}
} else {
// syntax: obj.prop
if (!is_stmt<identifier>(this->property)) {
@@ -0,0 +1,17 @@
diff --git a/common/jinja/runtime.cpp b/common/jinja/runtime.cpp
index f81d98d..5a089d3 100644
--- a/common/jinja/runtime.cpp
+++ b/common/jinja/runtime.cpp
@@ -779,6 +779,12 @@ value member_expression::execute_impl(context & ctx) {
} else {
property = this->property->execute(ctx);
}
+ } else if (is_stmt<integer_literal>(this->property)) {
+ // syntax: obj.index
+ property = mk_val<value_int>(cast_stmt<integer_literal>(this->property)->val);
+ if (property->as_int() < 0) {
+ throw std::runtime_error("Static member property cannot be negative");
+ }
} else {
// syntax: obj.prop
if (!is_stmt<identifier>(this->property)) {