From bb92a9e0b46c3af4f48c18a03f1f0b9e236c676e Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 6 Nov 2025 21:23:20 -0800 Subject: [PATCH] fix edge case --- src/compiler/tests/literals.test.ts | 8 +++++++- src/parser/curlyTokenizer.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/compiler/tests/literals.test.ts b/src/compiler/tests/literals.test.ts index c3481f2..03858e3 100644 --- a/src/compiler/tests/literals.test.ts +++ b/src/compiler/tests/literals.test.ts @@ -193,4 +193,10 @@ describe('curly strings', () => { expect(`{ This is $({twisted}). }`).toEvaluateTo(` This is twisted. `) expect(`{ This is $({{twisted}}). }`).toEvaluateTo(` This is {twisted}. `) }) -}) \ No newline at end of file + + test('interpolation edge cases', () => { + expect(`{[a=1 b=2 c={wild}]}`).toEvaluateTo(`[a=1 b=2 c={wild}]`) + expect(`a = 1;b = 2;c = 3;{$a $b $c}`).toEvaluateTo(`1 2 3`) + expect(`a = 1;b = 2;c = 3;{$a$b$c}`).toEvaluateTo(`123`) + }) +}) diff --git a/src/parser/curlyTokenizer.ts b/src/parser/curlyTokenizer.ts index 6a6de66..bc8acf0 100644 --- a/src/parser/curlyTokenizer.ts +++ b/src/parser/curlyTokenizer.ts @@ -49,7 +49,7 @@ export const tokenizeCurlyString = (value: string): (string | [string, Tree])[] const input = value.slice(start + 1, pos) // skip '$' tokens.push([input, parser.parse(input)]) - start = pos + start = pos-- // backtrack and start over } }