Closed JulienBacquart closed 4 months ago
Thanks, @JulienBacquart : This is a great catch. And I definitely appreciate the potential solution you propose. Let me give this one a little more thought - on the one hand, you're absolutely right that supporting the different type/binary operations is a can of worms...on the other hand, if we want to keep the promise of full support we probably should. Hmm. It's a bit of a conundrum. Let me give it a bit of thought.
In either case, supporting the +
should be something that gets tackled in the next release.
Implementing completely Binary Expression would mean implementing all the following operators and all the possible combinaison of types possibles:
operator: 'instanceof' | 'in' | '+' | '-' | '*' | '/' | '%' | '**' |
'|' | '^' | '&' | '==' | '!=' | '===' | '!==' |
'<' | '>' | '<=' | '<<' | '>>' | '>>>';
At this point you are re-implementing a whole javascript interpreter. And I don't know much JS, but even I know that you can write some pretty cursed expression in JS because of the casting never failing:
"b" + "a" + +"a" + "a"; // -> 'baNaNa'
Trying to reproduce Stacked percentage column
It seems the
+
is often used in the JS examples to break lines too long, but it breaks thefrom_js_literal()
function.If we look at the parse tree generated by Esprima
We can see we generate a
BinaryExpression
which is not a value type covered by js_literal_functions().A possible solution could look something like that:
If you want to open the can of worm of all valid combinaisons of types and binary operations, so we could write thing like
min : 0.8 * 100,
ortext: 'Domestic passenger for the year ' + 2012,
, is for you to decide.