Skip to content

Commit e772966

Browse files
committed
guard Found from being clobbered
1 parent 75cc02a commit e772966

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Nest/CommonAbstractions/Infer/Field/FieldExpressionVisitor.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ namespace Nest
1414
{
1515
internal class HasConstantExpressionVisitor : ExpressionVisitor
1616
{
17-
public bool Found { get; private set; }
17+
private bool _found;
18+
public bool Found
19+
{
20+
get { return _found; }
21+
// This is only set to true once to prevent clobbering from subsequent node visits
22+
private set { if (!_found) _found = value; }
23+
}
1824

1925
public HasConstantExpressionVisitor(Expression e)
2026
{
@@ -23,7 +29,7 @@ public HasConstantExpressionVisitor(Expression e)
2329

2430
public override Expression Visit(Expression node)
2531
{
26-
if (!Found)
32+
if (!this.Found)
2733
return base.Visit(node);
2834
return node;
2935
}

0 commit comments

Comments
 (0)