Skip to content

Commit e44e483

Browse files
authored
Update ARM JSON type loader to support optional type constraints (#18307)
Resolves #18217 ArmTemplateTypeLoader was not updated to support ARM schemas without a "type" constraint, so it was using a type of `error` in place of a type of `any`.
1 parent 1af0360 commit e44e483

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/Bicep.Core.IntegrationTests/ScenarioTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7460,4 +7460,52 @@ public void Test_FilePathMustBeRelative()
74607460

74617461
result.Should().ContainDiagnostic("BCP051", DiagnosticLevel.Error, "The specified path seems to reference an absolute path. Files must be referenced using relative paths.");
74627462
}
7463+
7464+
[TestMethod]
7465+
public void Test_Issue18217()
7466+
{
7467+
var result = CompilationHelper.CompileParams(
7468+
("parameters.bicepparam", """
7469+
using 'mod.json'
7470+
7471+
param foo = 'bar'
7472+
"""),
7473+
("mod.json", """
7474+
{
7475+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
7476+
"contentVersion": "1.0.0.0",
7477+
"parameters": {
7478+
"foo": {}
7479+
},
7480+
"resources": []
7481+
}
7482+
"""));
7483+
7484+
result.Should().NotHaveAnyDiagnostics();
7485+
}
7486+
7487+
[TestMethod]
7488+
public void Test_Issue18217_module()
7489+
{
7490+
var result = CompilationHelper.Compile(
7491+
("main.bicep", """
7492+
module mod 'mod.json' = {
7493+
params: {
7494+
foo: 'bar'
7495+
}
7496+
}
7497+
"""),
7498+
("mod.json", """
7499+
{
7500+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
7501+
"contentVersion": "1.0.0.0",
7502+
"parameters": {
7503+
"foo": {}
7504+
},
7505+
"resources": []
7506+
}
7507+
"""));
7508+
7509+
result.Should().NotHaveAnyDiagnostics();
7510+
}
74637511
}

src/Bicep.Core/TypeSystem/ArmTemplateTypeLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static ITypeReference ToTypeReferenceIgnoringNullability(SchemaValidatio
5656
TemplateParameterType.Array => GetArrayType(context, withResolvedRefs),
5757
TemplateParameterType.Object => GetObjectType(context, withResolvedRefs, flags),
5858
TemplateParameterType.SecureObject => GetObjectType(context, withResolvedRefs, flags | TypeSymbolValidationFlags.IsSecure),
59-
_ => ErrorType.Empty(),
59+
_ => LanguageConstants.Any,
6060
};
6161
}
6262

0 commit comments

Comments
 (0)