当 反向索引运算符 (^) 用于不受支持的类型的表达式(如对象、bool 或 int)时,会发生此诊断。
DESCRIPTION
^
索引运算符不能用于类型的<data-type>
基表达式。
级别
错误
例子
以下代码尝试对触发 BCP414 的对象使用 ^
运算符。
var config = {
name: 'example'
value: 42
}
output result any = config[^1] // Error: BCP414 - The "^" indexing operator cannot be used on base expressions of type "object".
对象属性没有排序,因此无法反向访问它们。
^
使用方括号表示法访问属性时,也不支持该运算符。
var config = {
'property name': 'example'
value: 42
}
output result string = config['property name']
后续步骤
有关 Bicep 诊断的详细信息,请参阅 Bicep 核心诊断。