BinaryIntegerLiterals, OctalIntegerLiterals, HexIntegerLiterals should not have a decimal point afer them - fixes #2402
This commit is contained in:
parent
75cd1a5531
commit
4f57a7b092
@ -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