ludic/examples/lang/nested_templates.ludic
Orkuncakilkaya afa4d23a4f fix(lang): a template inside another's hole, and integer literals past 2^31 - 1
A template literal nested in a {...} hole crashed the parser: the outer
literal ended at the inner backtick. The lexer (and ludic-fmt's) now
reads a hole as code, taking strings, chars and templates in it whole.
A decimal literal past 2147483647, or a hex one of more than eight
digits, was wrapped into a negative int; it is a long with its value
now, and giving one to an int is refused. Reseed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 08:10:46 +03:00

12 lines
479 B
Text

# nested_templates.ludic — a template literal inside another's hole is one expression: the outer
# literal ends at its own backtick, not at the inner one's. A brace or a backtick inside a string in
# a hole is text, and {{ }} are still literal braces.
#
# Running it prints: outer [inner 3 {x}] "`}" end
program NestedTemplates {
function wrap(s: string) -> string { return `[{s}]` }
entry {
let n = 3
print(`outer {wrap(`inner {n} {{x}}`)} {"\"`}\""} end`)
}
}