Skip to content

Commit 276bcce

Browse files
committed
cue/parser: add test case for string interpolation edge case
The logic for parsing string interpolations assumes that if there's an open-paren after a segment of a string interpolation, it's the start of an interpolation expression. That's not necessarily the case. This CL adds a test case for this before fixing it in a subsequent CL. Signed-off-by: Roger Peppe <[email protected]> Change-Id: If272c30278dbe74ae27a95512706d1c1c26e8c7e Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1223784 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 7e9543b commit 276bcce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cue/parser/parser_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ cannot import package as definition identifier`,
569569
'''`,
570570
out: `a: "foo \(ident)", b: "bar \(bar) $$$ ", c: "nest \({a: "\(nest) "}.a) \(5)", m1: """` + "\n\t\t\t multi \\(bar)\n\t\t\t \"\"\", m2: '''\n\t\t\t \\(bar) multi\n\t\t\t '''",
571571
},
572+
{
573+
desc: "paren after interpolation",
574+
in: `"\(1)"()`,
575+
// Note: this actually masks an out-of-bounds slice index panic
576+
// in scanner.Scanner.popInterpolation.
577+
out: "\nexpected operand, found ')' (and 1 more errors)",
578+
},
572579
{
573580
desc: "file comments",
574581
in: `// foo

0 commit comments

Comments
 (0)