Skip to content

Commit 08003c8

Browse files
committed
update
1 parent 400dce1 commit 08003c8

File tree

1 file changed

+15
-37
lines changed
  • articles/azure-resource-manager/bicep/diagnostics

1 file changed

+15
-37
lines changed

articles/azure-resource-manager/bicep/diagnostics/bcp414.md

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,45 @@
11
---
22
title: BCP414
3-
description: The spread operator "..." is not permitted in this location.
3+
description: The `^` indexing operator cannot be used on base expressions of type <base-type>.
44
ms.topic: reference
55
ms.custom: devx-track-bicep
66
ms.date: 05/20/2025
77
---
88

99
# Bicep diagnostic code - BCP414
1010

11-
This diagnostic occurs when you use expressions to define resource bodies as the [`Spread`](../operator-spread.md) operator gets converted to a function. It's a limitation in JSON.
11+
This diagnostic occurs when the reverse index operator (^) is used on an expression of an unsupported type, such as object, bool, or int.
1212

1313
## Description
1414

15-
The spread operator "..." is not permitted in this location.
15+
The `^` indexing operator cannot be used on base expressions of type \<base-type>.
1616

1717
## Level
1818

1919
Error
2020

2121
## Examples
2222

23-
The following example raises the diagnostic because the `spread` operator is used to define the resource body:
23+
The following code attempts to use the ^ operator on an object, which triggers BCP414.
2424

2525
```bicep
26-
param location string = resourceGroup().location
27-
param addressPrefix string = '10.0.0.0/24'
28-
29-
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
30-
name: 'vnetName'
31-
location: location
32-
33-
...(addressPrefix != '' ? {
34-
properties: {
35-
addressSpace: {
36-
addressPrefixes: [
37-
addressPrefix
38-
]
39-
}
40-
}
41-
} : {})
26+
var config = {
27+
name: 'example'
28+
value: 42
4229
}
30+
31+
output result any = config[^1] // Error: BCP414 - The "^" indexing operator cannot be used on base expressions of type "object".
4332
```
4433

45-
You can fix the diagnostic by using the operator in the lower level:
34+
To access properties of an object, use the `.` operator instead of `^`. The following code corrects the previous example.
4635

4736
```bicep
48-
param location string = resourceGroup().location
49-
param addressPrefix string = '10.0.0.0/24'
50-
51-
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
52-
name: 'vnetName'
53-
location: location
54-
55-
properties: {
56-
addressSpace: {
57-
...(addressPrefix != '' ? {
58-
addressPrefixes: [
59-
addressPrefix
60-
]
61-
} : {})
62-
}
63-
}
37+
var config = {
38+
name: 'example'
39+
value: 42
6440
}
41+
42+
output result string = config.name
6543
```
6644

6745
## Next steps

0 commit comments

Comments
 (0)