Misleading Unused Variable Warnings if there's a syntax error in the file
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
Bicep CLI version 0.4.613 (d826ce8411)
**Describe the bug**
If there is a syntax error in the file making it unparseable, the unused variable warning can fire even if the variable is actually used. In the below example, the `accountName` variable most certainly is used, but I presume the usage isn't detected as a knock on from the parser error (lack of closing brace on the resource).
**To Reproduce**
Build the following bicep snippet
```bicep
var accountName = 'SomeName'
resource x 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: accountName
```

Contributor guide
Research direction
Start by reproducing the warning with the Bicep snippet in the issue and inspect the compiler diagnostics for the syntax error and unused-variable warning. Done means the incomplete resource still reports its syntax error without incorrectly warning that accountName is unused.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100