Fix invalid codegen for non decimal numeric literals in MemberExpression

Fixes T7156
This commit is contained in:
Henry Zhu 2016-02-28 20:31:37 -05:00
parent 6aff776124
commit 35ed18f628
3 changed files with 16 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import * as n from "../node";
const SCIENTIFIC_NOTATION = /e/i;
const ZERO_DECIMAL_INTEGER = /\.0+$/;
const NON_DECIMAL_LITERAL = /^0[box]/;
export function UnaryExpression(node: Object) {
let needsSpace = /[a-z]$/.test(node.operator);
@ -225,7 +226,11 @@ export function MemberExpression(node: Object) {
} else {
if (t.isNumericLiteral(node.object)) {
let val = this.getPossibleRaw(node.object) || node.object.value;
if (isInteger(+val) && !SCIENTIFIC_NOTATION.test(val) && !ZERO_DECIMAL_INTEGER.test(val) && !this.endsWith(".")) {
if (isInteger(+val) &&
!NON_DECIMAL_LITERAL.test(val) &&
!SCIENTIFIC_NOTATION.test(val) &&
!ZERO_DECIMAL_INTEGER.test(val) &&
!this.endsWith(".")) {
this.push(".");
}
}

View File

@ -0,0 +1,5 @@
1..toString;
2..toString();
0x1F7.toString();
0b111110111.toString();
0o767.toString();

View File

@ -0,0 +1,5 @@
1..toString;
2..toString();
0x1F7.toString();
0b111110111.toString();
0o767.toString();