glimmerjs / glimmer-vm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve error message when attempting to conditionally render a named block

steveszc opened this issue · comments

Currently when attempting to render a named block inside of another block the error message is not very clear.

Developers who are new to named blocks may assume that they work similarly to other glimmer template constructs, and assume that they can be conditionally rendered with an if or rendered within a looping construct like each or each-in.

Since many developers will discover this limitation of named-blocks by trying it and seeing this error, it would be good to have a more clear and helpful error message. Currently the message is Unexpected named block nested in a normal block.

I suggest that the error message should note what kind of block the named block was nested with in, and explain that this is not allowed/supported. The current phrasing "unexpected named block" does not fully communicate that this is actually not a supported use for named blocks, and the phrase "normal block" is not commonly used vernacular for referring to template blocks like if/else/unless/each/each-in. Thus it may not be clear to the developer reading the error message what the problem actually is or how to fix it.

Error message source:

throw generateSyntaxError(`Unexpected named block nested in a normal block`, this.loc);