Parse MacroVar with empty expressions: %var{}#16772
Parse MacroVar with empty expressions: %var{}#16772straight-shoota wants to merge 3 commits intocrystal-lang:masterfrom
MacroVar with empty expressions: %var{}#16772Conversation
|
This change effectively introduces new valid syntax so maybe it's worth a slightly deeper discussion. Maybe it's best to turn it into an explicit error instead? I wouldn't call it a necessary generalization because I think there were some issues solved long ago where splatting of 0 arguments inside macros was made to work, and it was necessary because the input could be any number of args. But this is not like that, there's no way to use this syntax in a programmatic way |
|
Even if there is no programmatic way to produce this syntax, it could still appear when rewriting code. The syntax is pretty unambiguous. What else could |
|
I'm fine with either a proper parser error or accepting the syntax. |
This change adds specs to document the current behaviour, which seems very incorrect: We shouldn't be parsing `MacroVar` inside a literal. It doesn't affect the result when the macro var syntax is valid, but it easily breaks when it's not (see #16772 for example)
|
@straight-shoota the assertion from #16778 is now failing. |
Fixes the parser choking on
%var{}in a macro context.It might be debatable whether a macro var with empty expressions should be valid syntax. It doesn't make much sense semantically. But I don't see a good reason why it shouldn't.
Similar to #16741, this seems like an omission. Any number of expressions should be acceptable, including zero.