Skip to content

Commit

Permalink
Fix for issue 7455
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin authored Jul 5, 2022
1 parent a2b7970 commit 71b1746
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
23 changes: 23 additions & 0 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3748,5 +3748,28 @@ param storageAccountSku string
result.Template.Should().HaveValueAtPath("$.resources[1].type", "Microsoft.Storage/storageAccounts");
result.Template.Should().NotHaveValueAtPath("$.resources[1].dependsOn");
}

/// <summary>
/// https://github.com/Azure/bicep/issues/7455
/// </summary>
[TestMethod]
public void Test_Issue7455()
{
var result = CompilationHelper.Compile(@"
var test1 = {
'tata':'loco'
}
var test2 = {
'tata':'cola'
}
param useFirst bool = true
var value = (useFirst ? test1 : test2).tata
").ExcludingLinterDiagnostics();

result.Should().NotHaveAnyDiagnostics();
}
}
}
14 changes: 0 additions & 14 deletions src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ public DeclaredTypeManager(TypeManager typeManager, IBinder binder)

public TypeSymbol? GetDeclaredType(SyntaxBase syntax) => this.GetDeclaredTypeAssignment(syntax)?.Reference.Type;

private DeclaredTypeAssignment? GetParentTypeAssignment(SyntaxBase syntax)
{
if (binder.GetParent(syntax) is {} parent)
{
return GetTypeAssignment(parent);
}

return null;
}

private DeclaredTypeAssignment? GetTypeAssignment(SyntaxBase syntax)
{
RuntimeHelpers.EnsureSufficientExecutionStack();
Expand Down Expand Up @@ -114,10 +104,6 @@ public DeclaredTypeManager(TypeManager typeManager, IBinder binder)

case FunctionArgumentSyntax functionArgument:
return GetFunctionArgumentType(functionArgument);

case ParenthesizedExpressionSyntax:
case TernaryOperationSyntax:
return GetParentTypeAssignment(syntax);
}

var parent = binder.GetParent(syntax);
Expand Down

0 comments on commit 71b1746

Please sign in to comment.