Commit 63b642b
authored
Enable parameter files to evaluate variables from extended base parameters (#18626)
Fixes #18625
## Description
Build params was not evaluating variables declared in base .bicepparam
files when using extends, which led to missing/incorrect values in
derived parameter files. This change adds evaluation of variables and
parameter assignments across the extends chain and adds integration
tests for simple and complex base variables to ensure merged params
produce the expected values.
Modified `ParameterAssignmentEvaluator` to create per-file evaluation
contexts. Each variable and parameter is now evaluated using only the
symbols defined in its own file.
Scenario 1
```bicep
// base.bicepparam
using none
param foo = 'abc'
var x = foo
param bar = x
// main.bicepparam
using './main.bicep'
extends './base.bicepparam'
param foo = 'def'
// output
bar = 'abc'
foo = 'def'
// bar equals 'abc' because base's "var x" uses base's foo='abc', not main's override foo='def'
```
Scenario 2
```bicep
// base.bicepparam
using none
var x = 'foo'
param p1 = 'p-${x}'
// main.bicepparam
using './main.bicep'
extends './base.bicepparam'
var x = 'bar'
param p2 = 'p-${x}'
// output
p1 = "p-foo"
p2 = "p-bar"
// Each file's parameter uses its own x variable value
```
Scenario 3
```bicep
// base.bicepparam
using none
var x = 'foo'
param p1 = 'p-${x}'
// main.bicepparam
using './main.bicep'
extends './base.bicepparam'
param p2 = 'p-${x}'
// output
p1 = "p-foo"
p2 = "p-foo"
// Main can reference base's x (semantic binding allows it), but x is evaluated in base's scope
```
## Checklist
- [x] I have read and adhere to the [contribution
guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md).
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/18626)1 parent d4b28b6 commit 63b642b
File tree
4 files changed
+664
-54
lines changed- src
- Bicep.Cli.IntegrationTests
- Bicep.Core
- Emit
- Semantics
4 files changed
+664
-54
lines changed
0 commit comments