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
The problem seems to be because locations is being considered as type 'northeurope'[] | array rather than just array. A workaround for this behaviour is to explicitly testLocations to be an array type, but I wouldn't expect this cast to be needed
Related to #449 and #1735. I think we need a mechanism to simplify redundant union types in the type system. For this specific issue, we need to simplify the type of the item in an array type. But there are other cases. For example, string | 'a' | 'b' is equivalent to string. Similarly string | string is the same as the string type.
In addition to not simplifying redundant union types, we're also not handling union types correctly when type checking array access expressions. Indexing over a type like 'northeurope'[] | array via an integer should produce an item type of 'northeurope' | any or just any once we have the logic to implify redundant union types.
A similar problem exists with the logic that type checks property access expressions.
Bicep version
0.3.255 (VS Code)
Describe the bug
In the below code
locations
always gets set to some form of array, however trying to index intoregions
results in the errorTo Reproduce
Additional context
The problem seems to be because
locations
is being considered as type'northeurope'[] | array
rather than justarray
. A workaround for this behaviour is to explicitlytestLocations
to be an array type, but I wouldn't expect this cast to be neededThe text was updated successfully, but these errors were encountered: