Azure / Azure/bicep

Loops not supported in variable definition with ternary operator

Open
#6,960 1 comment 1 reaction 0 assignees View on GitHub
enhancement intermediate language
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
v0.6.18

**Describe the bug**
Cannot define a variable with a ternary operator and a loop being used in one of the operator arguments.

**To Reproduce**
```bicep
var foo = true ? [for i in range(0,10): i] : []
output fooout array = foo
```

>For-expressions are not supported in this context. For-expressions may be used as values of resource, module, variable, and output declarations, or values of resource and module properties.bicep(BCP138)

Contributor guide

Open the contributing guide

Research direction

Start by compiling the reproduction in the issue with Bicep v0.6.18 and trace the diagnostic that rejects the for-expression inside the ternary operator. Determine the compiler behavior needed for this expression to compile, then verify that the reproduction succeeds without regressing the existing for-expression restrictions.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.