Merge pull request #2403 from alawatthe/double-decimal-point
BinaryIntegerLiterals, OctalIntegerLiterals, HexIntegerLiterals shoul…
This commit is contained in:
commit
8ab4a5df43
@ -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(".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,3 +9,6 @@ foo[test()][bar()];
|
||||
|
||||
0..toString();
|
||||
0.5.toString();
|
||||
0b111.toString(16);
|
||||
0o111.toString(16);
|
||||
0x111.toString(16);
|
||||
|
||||
@ -9,3 +9,6 @@ foo[test()][bar()];
|
||||
|
||||
0..toString();
|
||||
0.5.toString();
|
||||
0b111.toString(16);
|
||||
0o111.toString(16);
|
||||
0x111.toString(16);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user