Skip to content

Commit

Permalink
fix: Merge custom context in correct order
Browse files Browse the repository at this point in the history
When adding a variable to a custom context then the variable is wrapped in a static context and both contexts are combined.

The combined context contains all variables in the order: custom context and then static context with new variable. On accessing a variable from the combined context, it looks for the variable in the custom context first. As a result, the new variable can't be accessed if a variable with the same name exists in the custom context.

The behavior is different for a static context. The new variable is added to the static context and overrides a previous variable with the same name.

Align the behavior for a custom context with the behavior of a static context. A new variable should override/shadow an existing variable.

(cherry picked from commit 626aa4d)
  • Loading branch information
saig0 authored and github-actions[bot] committed Jan 2, 2024
1 parent f5cff6e commit a3d93d5
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ object EvalContext {
case (StaticVariableProvider(thisVariables), StaticVariableProvider(otherVariables)) =>
StaticVariableProvider(thisVariables ++ otherVariables)
case (thisProvider, otherProvider) =>
CompositeVariableProvider(List(thisProvider, otherProvider))
CompositeVariableProvider(List(otherProvider, thisProvider))
}
}

Expand All @@ -195,7 +195,7 @@ object EvalContext {
StaticFunctionProvider(allFunctions)
}
case (thisProvider, otherProvider) =>
CompositeFunctionProvider(List(thisProvider, otherProvider))
CompositeFunctionProvider(List(otherProvider, thisProvider))
}
}

Expand Down

0 comments on commit a3d93d5

Please sign in to comment.