bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Misleading second error if using `=` for a property value rather than `:`

Open afscrome opened this issue 5 years ago • 1 comments

Is your feature request related to a problem? Please describe. Consider the following bicep. Whilst this is wrong bicep, it is increadibly easy to write if you're familiar with other programming languages which use = rather than :, and have a brain fart.

var foo = {
  name = 'value${deployment().name}'
}

Whilst the first error is correct, the second error could is a bit misleading, and is just a consequence of the parser getting confused

image

Describe the solution you'd like Could the parser's error handling better handle this error such that the second error doesn't get reported?

afscrome avatar Apr 29 '21 22:04 afscrome

Thanks for your patience — this was recently picked up as an outstanding open issue for the Bicep team to review.

Reproduced on Bicep 0.43.8. The first diagnostic is the right one:

BCP018: Expected the ":" character at this location.

…but the parser still emits a second, cascading diagnostic after it:

BCP009: Expected a literal value, an array, an object, a parenthesized expression, or a function call at this location.

So the redundant follow-on error you flagged is still there — it's a parser error-recovery artifact, exactly as you described. I'm going to leave this open as a tracked error-message polish so we trim the cascading diagnostic once it's picked up. Feel free to reopen if you'd like to add other =-vs-: cases.

torreymicrosoft avatar Jun 10 '26 18:06 torreymicrosoft