Azure / Azure/bicep

Inconsistency of type `int` allowing `null` in some scenarios, but not other

Open
#5,938 8 comments 6 reactions 0 assignees View on GitHub
type system
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
VSCode v0.4.1124

**Describe the bug**
The bicep language seems somewhat inconsistent as to whether it allows null. In the below example, both scenarios describe a value of type `int`, however one allows null, and one doesn't.

Assuming this is the desired behaviour
1. I'd like to see there be some difference in the type to make clear whether null is allowed. (e.g. the hover over for `capacityReservationLevel` should show the type as `int?` or `int | null` )
2. Is there a way to specify that a parameter can be a nullable int.

**To Reproduce**
`capacityReservationLevel` is described as type `int` and allows `null`
![image](https://user-images.githubusercontent.com/289860/153510559-38029149-3152-400b-9b9b-ff2fdb76c95f.png)

However if you have a parameter of type `int`, then null isn't allowed
![image](https://user-images.githubusercontent.com/289860/153510710-8260d722-1686-48fd-85bd-8214696e0c4a.png)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two cases in VSCode v0.4.1124: the resource property's `int` value that accepts `null` and an `int` parameter that rejects it. Compare the language's type display and null validation, then verify that the accepted behavior and any nullable-type notation are consistent and covered by tests or documentation.

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.