Skip to content

Commit 18ee4be

Browse files
authored
Merge pull request #98 from nblumhardt/bind-locals-in-rep-enumerable
Bind template locals appearing in repetition enumerable expressions
2 parents 1460b49 + e2b6d6a commit 18ee4be

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Serilog.Expressions/Templates/Compilation/NameResolution/TemplateLocalNameResolver.cs renamed to src/Serilog.Expressions/Templates/Compilation/NameResolution/TemplateLocalNameBinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Template Transform(Repetition rep, Stack<string> locals)
7676
locals.Pop();
7777

7878
return new Repetition(
79-
rep.Enumerable,
79+
ExpressionLocalNameBinder.BindLocalValueNames(rep.Enumerable, locals),
8080
rep.BindingNames,
8181
body,
8282
rep.Delimiter != null ? Transform(rep.Delimiter, locals) : null,

test/Serilog.Expressions.Tests/Cases/template-evaluation-cases.asv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ A{#if false}B{#else if true}C{#end} ⇶ AC
2525
{#each a in [1,2,3]}<{a}>{#delimit},{#end} ⇶ <1>,<2>,<3>
2626
{#each a in {x: 1, y: 2}}{a}{#end} ⇶ xy
2727
{#each a, b in {x: 1, y: 2}}{a}.{b}{#end} ⇶ x.1y.2
28+
{#each a, b in {x: {y: 'z'}}}{#each c, d in b}A: {a}, C: {c}, D: {d}{#end}{#end} ⇶ A: x, C: y, D: z
2829
{#if true}A{#each a in [1]}B{a}{#end}C{#end}D ⇶ AB1CD
2930
{#each a in []}{a}!{#else}none{#end} ⇶ none
3031
Culture-specific {42.34} ⇶ Culture-specific 42,34

0 commit comments

Comments
 (0)