diff --git a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs index c1da621a361..30bc0192f1a 100644 --- a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs +++ b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs @@ -5622,6 +5622,27 @@ public void Test_Issue12908() }); } + // https://github.com/Azure/bicep/issues/13531 + [TestMethod] + public void Test_Issue13531() + { + var result = CompilationHelper.CompileParams( + ("parameters.bicepparam", """ +using 'main.bicep' + +param location = location +"""), + ("main.bicep", """ +#disable-next-line no-unused-params +param location string +""")); + + result.Should().HaveDiagnostics(new[] + { + ("BCP079", DiagnosticLevel.Error, """This expression is referencing its own declaration, which is not allowed."""), + }); + } + [TestMethod] public void Functions_can_be_imported_in_bicepparam_files() { diff --git a/src/Bicep.Core/Emit/EmitLimitationCalculator.cs b/src/Bicep.Core/Emit/EmitLimitationCalculator.cs index 6acf40f6a2a..1ca90630f75 100644 --- a/src/Bicep.Core/Emit/EmitLimitationCalculator.cs +++ b/src/Bicep.Core/Emit/EmitLimitationCalculator.cs @@ -513,6 +513,13 @@ private static void BlockCyclicAggregateTypeReferences(SemanticModel model, IDia foreach (var symbol in GetTopologicallySortedSymbols(referencesInValues)) { + if (symbol.Type is ErrorType) + { + // no point evaluating if we're already reporting an error + erroredSymbols.Add(symbol); + continue; + } + var referencedValueHasError = false; foreach (var referenced in referencesInValues[symbol]) { @@ -547,13 +554,6 @@ private static void BlockCyclicAggregateTypeReferences(SemanticModel model, IDia continue; } - if (parameter.Type is ErrorType) - { - // no point evaluating if we're already reporting an error - erroredSymbols.Add(parameter); - continue; - } - // We may emit duplicate errors here - type checking will also execute some ARM functions and generate errors // This is something we should improve before the first release. var result = evaluator.EvaluateParameter(parameter);