You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolves#13399
This PR adds a new ambient type symbol (`any`) to take advantage of
`"type"` constraints being made optional in ARM's **w34** release.
Anywhere type syntax is expected, users can now supply `any`:
```bicep
param foo any
output bar any = foo
func cowSay(toSay any) string => 'The cow says, "${toSay}"'
```
`any` is incompatible with the `@secure()` decorator.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/17848)
Copy file name to clipboardExpand all lines: src/Bicep.Core.IntegrationTests/ScenarioTests.cs
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ param l
83
83
("BCP028",DiagnosticLevel.Error,"Identifier \"l\" is declared multiple times. Remove or rename the duplicates."),
84
84
("BCP079",DiagnosticLevel.Error,"This expression is referencing its own declaration, which is not allowed."),
85
85
("BCP028",DiagnosticLevel.Error,"Identifier \"l\" is declared multiple times. Remove or rename the duplicates."),
86
-
("BCP279",DiagnosticLevel.Error,"Expected a type at this location. Please specify a valid type expression or one of the following types: \"array\", \"bool\", \"int\", \"object\", \"string\"."),
86
+
("BCP279",DiagnosticLevel.Error,"Expected a type at this location. Please specify a valid type expression or one of the following types: \"any\", \"array\", \"bool\", \"int\", \"object\", \"string\"."),
("BCP279",DiagnosticLevel.Error,"Expected a type at this location. Please specify a valid type expression or one of the following types: \"array\", \"bool\", \"int\", \"object\", \"string\"."),
795
+
("BCP279",DiagnosticLevel.Error,"Expected a type at this location. Please specify a valid type expression or one of the following types: \"any\", \"array\", \"bool\", \"int\", \"object\", \"string\"."),
796
796
});
797
797
}
798
798
@@ -5776,8 +5776,8 @@ public void Test_Issue12908()
("BCP308",DiagnosticLevel.Error,"""The decorator "secure" may not be used on statements whose declared type is a reference to a user-defined type."""),
5780
-
("BCP308",DiagnosticLevel.Error,"""The decorator "secure" may not be used on statements whose declared type is a reference to a user-defined type."""),
5779
+
("BCP439",DiagnosticLevel.Error,"""The @secure() decorator can only be used on statements whose type clause is "string,", "object", or a literal type."""),
5780
+
("BCP439",DiagnosticLevel.Error,"""The @secure() decorator can only be used on statements whose type clause is "string,", "object", or a literal type."""),
("BCP302",DiagnosticLevel.Error,"""The name "invalid" is not a valid type. Please specify one of the following types: "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string"."""),
80
+
("BCP302",DiagnosticLevel.Error,"""The name "invalid" is not a valid type. Please specify one of the following types: "any", "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string"."""),
Copy file name to clipboardExpand all lines: src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs
+61-18Lines changed: 61 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -155,7 +155,7 @@ param intParam constrainedInt
155
155
("BCP308",DiagnosticLevel.Error,"The decorator \"maxValue\" may not be used on statements whose declared type is a reference to a user-defined type."),
156
156
("BCP308",DiagnosticLevel.Error,"The decorator \"minLength\" may not be used on statements whose declared type is a reference to a user-defined type."),
157
157
("BCP308",DiagnosticLevel.Error,"The decorator \"maxLength\" may not be used on statements whose declared type is a reference to a user-defined type."),
158
-
("BCP308",DiagnosticLevel.Error,"The decorator \"secure\" may not be used on statements whose declared type is a reference to a user-defined type."),
158
+
("BCP439",DiagnosticLevel.Error,"The @secure() decorator can only be used on statements whose type clause is \"string,\", \"object\", or a literal type."),
159
159
("BCP308",DiagnosticLevel.Error,"The decorator \"allowed\" may not be used on statements whose declared type is a reference to a user-defined type."),
160
160
("no-unused-params",DiagnosticLevel.Warning,"Parameter \"stringParam\" is declared but never used."),
161
161
("BCP308",DiagnosticLevel.Error,"The decorator \"minValue\" may not be used on statements whose declared type is a reference to a user-defined type."),
("BCP411",DiagnosticLevel.Error,"""The type "any" cannot be used in a type assignment because it does not fit within one of ARM's primitive type categories (string, int, bool, array, object). If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues."""),
("BCP432",DiagnosticLevel.Error,"This expression is being used in parameter \"predicate\" of the function \"validate\", which requires a value that can be calculated at the start of the deployment. You are referencing a variable which cannot be calculated at the start (\"indirection\" -> \"sa\"). Properties of sa which can be calculated at the start include \"apiVersion\", \"id\", \"name\", \"type\"."),
("BCP439",DiagnosticLevel.Error,"The @secure() decorator can only be used on statements whose type clause is \"string,\", \"object\", or a literal type."),
2000
+
("BCP439",DiagnosticLevel.Error,"The @secure() decorator can only be used on statements whose type clause is \"string,\", \"object\", or a literal type."),
Copy file name to clipboardExpand all lines: src/Bicep.Core.Samples/Files/baselines/InvalidExpressions_LF/main.diagnostics.bicep
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -448,7 +448,7 @@ var invalidPropertyAccessOnAzNamespace = az.az
448
448
//@[44:46) [BCP052 (Error)] The type "az" does not contain property "az". (bicep https://aka.ms/bicep/core-diagnostics#BCP052) |az|
449
449
varinvalidPropertyAccessOnSysNamespace = sys.az
450
450
//@[04:39) [no-unused-vars (Warning)] Variable "invalidPropertyAccessOnSysNamespace" is declared but never used. (bicep core linter https://aka.ms/bicep/linter-diagnostics#no-unused-vars) |invalidPropertyAccessOnSysNamespace|
451
-
//@[46:48) [BCP053 (Error)] The type "sys" does not contain property "az". Available properties include "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |az|
451
+
//@[46:48) [BCP053 (Error)] The type "sys" does not contain property "az". Available properties include "any", "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |az|
452
452
varinvalidOperands = 1 + az
453
453
//@[04:19) [no-unused-vars (Warning)] Variable "invalidOperands" is declared but never used. (bicep core linter https://aka.ms/bicep/linter-diagnostics#no-unused-vars) |invalidOperands|
454
454
//@[22:28) [BCP045 (Error)] Cannot apply operator "+" to operands of type "1" and "az". (bicep https://aka.ms/bicep/core-diagnostics#BCP045) |1 + az|
@@ -495,12 +495,12 @@ var azFunctions = az.a
495
495
// #completionTest(24) -> sysFunctions
496
496
varsysFunctions = sys.a
497
497
//@[04:16) [no-unused-vars (Warning)] Variable "sysFunctions" is declared but never used. (bicep core linter https://aka.ms/bicep/linter-diagnostics#no-unused-vars) |sysFunctions|
498
-
//@[23:24) [BCP053 (Error)] The type "sys" does not contain property "a". Available properties include "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |a|
498
+
//@[23:24) [BCP053 (Error)] The type "sys" does not contain property "a". Available properties include "any", "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |a|
499
499
500
500
// #completionTest(33) -> sysFunctions
501
501
varsysFunctionsInParens = (sys.a)
502
502
//@[04:24) [no-unused-vars (Warning)] Variable "sysFunctionsInParens" is declared but never used. (bicep core linter https://aka.ms/bicep/linter-diagnostics#no-unused-vars) |sysFunctionsInParens|
503
-
//@[32:33) [BCP053 (Error)] The type "sys" does not contain property "a". Available properties include "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |a|
503
+
//@[32:33) [BCP053 (Error)] The type "sys" does not contain property "a". Available properties include "any", "array", "bool", "int", "object", "resourceInput", "resourceOutput", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP053) |a|
//@[36:52) [BCP341 (Error)] This expression is being used inside a function declaration, which requires a value that can be calculated at the start of the deployment. (bicep https://aka.ms/bicep/core-diagnostics#BCP341) |reference('foo')|
3
3
4
4
funcmissingArgType(input) string => input
5
-
//@[25:26) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |)|
5
+
//@[25:26) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "any", "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |)|
6
6
7
7
funcmissingOutputType(inputstring) => input
8
-
//@[37:39) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |=>|
8
+
//@[37:39) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "any", "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |=>|
9
9
//@[45:45) [BCP009 (Error)] Expected a literal value, an array, an object, a parenthesized expression, or a function call at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP009) ||
10
10
//@[45:45) [BCP018 (Error)] Expected the "=>" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) ||
//@[15:15) [BCP015 (Error)] Expected a variable identifier at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP015) ||
62
-
//@[15:16) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |,|
62
+
//@[15:16) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "any", "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |,|
63
63
functrailingCommas(astring,,) string => 'foo'
64
64
//@[29:29) [BCP015 (Error)] Expected a variable identifier at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP015) ||
65
-
//@[29:30) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |,|
65
+
//@[29:30) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "any", "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |,|
66
66
funcmultiLineOnly(
67
67
astring
68
68
bstring) string => 'foo'
69
69
//@[02:03) [BCP018 (Error)] Expected the ")" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) |b|
70
70
//@[27:27) [BCP009 (Error)] Expected a literal value, an array, an object, a parenthesized expression, or a function call at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP009) ||
71
-
//@[27:27) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) ||
71
+
//@[27:27) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "any", "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) ||
72
72
//@[27:27) [BCP018 (Error)] Expected the "=>" character at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP018) ||
73
73
74
74
funcmultiLineTrailingCommas(
75
75
astring,
76
76
,) string => 'foo'
77
77
//@[02:02) [BCP015 (Error)] Expected a variable identifier at this location. (bicep https://aka.ms/bicep/core-diagnostics#BCP015) ||
78
-
//@[02:03) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |,|
78
+
//@[02:03) [BCP279 (Error)] Expected a type at this location. Please specify a valid type expression or one of the following types: "any", "array", "bool", "int", "object", "string". (bicep https://aka.ms/bicep/core-diagnostics#BCP279) |,|
0 commit comments