Representation of negative integer literals in the v1 format is odd
Unary expression to negate seems very inefficient
This kind of sounds like a parser error. Normally, -1 should be represented as a negative float in multipart (and as a 8 bit integer in entropy). Do you have a minimal example to reproduce this?
yes, it's from parser. not sure if this is "error" tho.
$ node
> console.log(JSON.stringify(require('shift-parser').parseScript("-1"), undefined, 2))
{
"type": "Script",
"directives": [],
"statements": [
{
"type": "ExpressionStatement",
"expression": {
"type": "UnaryExpression",
"operator": "-",
"operand": {
"type": "LiteralNumericExpression",
"value": 1
}
}
}
]
}
we can apply some filter in shift.rs or somewhere.
maybe we could solve this at the same time as https://github.com/binast/binjs-ref/issues/229 ?
FWIW this is a standard representation of negative numbers in JS parsers, as syntax spec technically doesn't define negative numbers. I agree it can be more efficient in custom formats like BinJS, but it's not really odd.
Actually disregard the deleted comment, I didn't see that Shift already converts any keys to strings.
Would anyone be interested in rewriting negative number translation to get rid of such oddities?
@vdjeric maybe?