Support footnote indexing inside interpolated call args and strings

Parse `` `var`[^key] `` in `` *…* `` segments and quoted strings as an
Index part (chained `` [^a][^b] `` folds into one part) in both the
tree-walk interpreter and the bytecode compiler, and render it back in
`view`. Also make bytecode `_type` stamping always overwrite like the
interpreter does, so child constructors yield the most specific type.

Adds gold/unit tests for interp footnote indexing and a bytecode
inherit-explicit-super case.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-24 14:45:56 +08:00
1 parent d7924ea8c7
commit b84e82eb56
10 files changed
+247 -6

No files matched your search

+13
View File
@@ -830,6 +830,19 @@ impl<'a> FnCompiler<'a> {
.ok_or_else(|| self.err(format!("undefined variable `{n}`")))?;
self.emit(Op::GetLocal(slot));
}
InterpPart::Index { base, labels } => {
let slot = self
.locals
.get(base)
.copied()
.ok_or_else(|| self.err(format!("undefined variable `{base}`")))?;
self.emit(Op::GetLocal(slot));
for label in labels {
let li = self.add_const(Value::Text(label.clone()));
self.emit(Op::Constant(li));
self.emit(Op::FootnoteGet);
}
}
}
if idx > 0 {
self.emit(Op::Add);