Skip to content

Commit

Permalink
Fix for issue 13531
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Mar 5, 2024
1 parent 0dbe38b commit 8d35e10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
21 changes: 21 additions & 0 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Expand Up @@ -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()
{
Expand Down
14 changes: 7 additions & 7 deletions src/Bicep.Core/Emit/EmitLimitationCalculator.cs
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8d35e10

Please sign in to comment.