Skip to content

Commit d5792f4

Browse files
authored
Merge pull request #300115 from mumian/0520-bcp414
Document bcp414
2 parents f3986c2 + 4fdf8b3 commit d5792f4

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ If you need more information about a particular diagnostic code, select the **Fe
389389
| <a id='BCP410' />BCP410 | Error | Division by zero is not supported. |
390390
| <a id='BCP411' />BCP411 | Error | The type `{type}` 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). |
391391
| <a id='BCP412' />BCP412 | Error | The variable type is not valid. Please specify one of the following types: `{ToQuotedString(validTypes)}`. |
392-
| <a id='BCP414' />BCP414 | Error | The `^` indexing operator cannot be used on base expressions of type `{baseType}`. |
392+
| <a id='BCP414' />[BCP414](./diagnostics/bcp414.md) | Error | The `^` indexing operator cannot be used on base expressions of type `{baseType}`. |
393393
| <a id='BCP415' />BCP415 | Error | The `^` indexing operator cannot be used with index expressions of type `{indexType}`. |
394394
| <a id='BCP416' />BCP416 | Error | The supplied string does not match the expected pattern of `{expectedPattern}`. |
395395
| <a id='BCP417' />BCP417 | Error | The spread operator `{ellipsis}` cannot be used inside objects with property for-expressions. |
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: BCP414
3+
description: The `^` indexing operator can't be used on base expressions of type <data-type>.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 05/27/2025
7+
---
8+
9+
# Bicep diagnostic code - BCP414
10+
11+
This diagnostic occurs when the [reverse index operator (^)](../operators-access.md#reverse-index-accessor) is used on an expression of an unsupported type, such as object, bool, or int.
12+
13+
## Description
14+
15+
The `^` indexing operator can't be used on base expressions of type `<data-type>`.
16+
17+
## Level
18+
19+
Error
20+
21+
## Examples
22+
23+
The following code attempts to use the `^` operator on an object, which triggers BCP414.
24+
25+
```bicep
26+
var config = {
27+
name: 'example'
28+
value: 42
29+
}
30+
31+
output result any = config[^1] // Error: BCP414 - The "^" indexing operator cannot be used on base expressions of type "object".
32+
```
33+
34+
Object properties aren't ordered, so they can't be accessed in reverse. The `^` operator also isn't supported when accessing properties with square bracket notation.
35+
36+
```bicep
37+
var config = {
38+
'property name': 'example'
39+
value: 42
40+
}
41+
42+
output result string = config['property name']
43+
```
44+
45+
## Next steps
46+
47+
For more information about Bicep diagnostics, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,5 +737,7 @@ items:
737737
href: diagnostics/bcp338.md
738738
- name: BCP401
739739
href: diagnostics/bcp401.md
740+
- name: BCP414
741+
href: diagnostics/bcp414.md
740742
- name: Azure CLI
741743
href: /cli/azure/resource

0 commit comments

Comments
 (0)