Merge pull request #2403 from alawatthe/double-decimal-point

BinaryIntegerLiterals, OctalIntegerLiterals, HexIntegerLiterals shoul…
This commit is contained in:
Sebastian McKenzie 2015-09-27 21:24:05 +01:00
commit 8ab4a5df43
3 changed files with 15 additions and 1 deletions

View File

@ -8,6 +8,13 @@ import * as t from "../../types";
const SCIENTIFIC_NOTATION = /e/i;
/**
* RegExp for testing if a numeric literal is
* a BinaryIntegerLiteral, OctalIntegerLiteral or HexIntegerLiteral.
*/
const NON_DECIMAL_NUMERIC_LITERAL = /^0(b|o|x)/i;
/**
* Prints UnaryExpression, prints operator and argument.
*/
@ -280,7 +287,8 @@ export function MemberExpression(node, print) {
} else {
if (t.isLiteral(node.object)) {
var val = this._Literal(node.object);
if (isInteger(+val) && !SCIENTIFIC_NOTATION.test(val) && !this.endsWith(".")) {
if (isInteger(+val) && !SCIENTIFIC_NOTATION.test(val) && !this.endsWith(".")
&& !NON_DECIMAL_NUMERIC_LITERAL.test(val)) {
this.push(".");
}
}

View File

@ -9,3 +9,6 @@ foo[test()][bar()];
0..toString();
0.5.toString();
0b111.toString(16);
0o111.toString(16);
0x111.toString(16);

View File

@ -9,3 +9,6 @@ foo[test()][bar()];
0..toString();
0.5.toString();
0b111.toString(16);
0o111.toString(16);
0x111.toString(16);