Skip to content

Commit

Permalink
Fix for issue 12417 (#12420)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Nov 10, 2023
1 parent 7d1609d commit 88c4ab8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
67 changes: 67 additions & 0 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5298,4 +5298,71 @@ public void Test_Issue11981()
("BCP037", DiagnosticLevel.Error, "The property \"baz\" is not allowed on objects of type \"{ bar: string }\". No other properties are allowed."),
});
}

// https://github.com/Azure/bicep/issues/12417
[TestMethod]
public void Test_Issue12417()
{
var result = CompilationHelper.CompileParams(
("parameters.bicepparam", @"
using 'test.bicep'
param azureEnvironments
param region = azureEnvironments.AzureCloud.eventHubName.dev
"),
("test.bicep", @"
@description('Azure environment specific configuration settings')
type AzureEnvironmentType = {
@description('Azure US Government specific settings')
AzureUSGovernment: {
@description('Azure Gov Event Hub ResourceIds')
eventHubName: {
prod: 'resourceId'
qa: 'resourceId'
dev: 'resourceId'
}
@description('Azure Gov supported regions')
region: {
usgovvirginia: 'ugv'
usgovtexas: 'ugt'
}
@description('Azure Gov Log Analytics ResourceIds')
workspace: {
prod: 'resourceId'
qa: 'resourceId'
dev: 'resourceId'
}
}
@description('Azure Global specific settings')
AzureCloud: {
@description('Azure Global Event Hub ResourceIds')
eventHubName: {
prod: 'resourceId'
qa: 'resourceId'
dev: 'resourceId'
}
@description('Azure Global supported regions')
region: {
eastus: 'eus'
westus: 'wus'
}
@description('Azure Global Log Analytics ResourceIds')
workspace: {
prod: 'resourceId'
qa: 'resourceId'
dev: 'resourceId'
}
}
}
param azureEnvironments AzureEnvironmentType
"));

result.Should().HaveDiagnostics(new[] {
("BCP018", DiagnosticLevel.Error, "Expected the \"=\" character at this location."),
("BCP259", DiagnosticLevel.Error, "The parameter \"region\" is assigned in the params file without being declared in the Bicep file."),
("BCP062", DiagnosticLevel.Error, "The referenced declaration with name \"azureEnvironments\" is not valid."),
});
}
}
3 changes: 1 addition & 2 deletions src/Bicep.Core/Emit/EmitLimitationCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,7 @@ private static void BlockCyclicAggregateTypeReferences(SemanticModel model, IDia
{
referencedValueHasError = true;
}

if (referenced.Key is ParameterAssignmentSymbol parameterAssignment)
else if (referenced.Key is ParameterAssignmentSymbol parameterAssignment)
{
if (generated[parameterAssignment].KeyVaultReferenceExpression is not null)
{
Expand Down

0 comments on commit 88c4ab8

Please sign in to comment.