google/closure-templates

Globals and "or" compiler warning

theindexer opened this issue · 0 comments

When I try to do something like
{if GLOBAL == 'x' or GLOBAL == 'y' or GLOBAL== 'z'}
I get a bushel (4, in fact - G==x or G==y, G==x, G==y, G==z) of compiler warnings like

warning: Constant operand 'GLOBAL == 'x' or GLOBAL == 'y'' used with 'or' operator. Consider simplifying 
or using the ?: operator, see go/soy/reference/expressions.md#logical-operators  

This seems like a fine use of the or operator to me. Yeah the GLOBAL's constant, but I don't know what it's going to be when I'm writing the template. It's my understanding that this is trying to prevent things like {if $x or true} or {let $x: $y or 5} but this is neither of those. The only way out I see to appease the compiler warning is adding some ?: and parens in which seems...unpleasant.

Am I missing something or is this just unfortunate?