From 1529ab965a4a434e6024977a53f8460f6a474086 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 16 Jan 2013 14:59:19 -0500 Subject: Fix output for arrays containing undefined values. 1b6bcca7 was a first attempt at this. That commit made Uglify stop replacing holes with undefined, but instead it started replacing undefined with holes. This is slightly problematic, because there is a difference between a hole and an undefined value. More problematically, it changed [1,undefined] to [1,] which generally doesn't even parse as a hole (just as a trailing comma), so it didn't even preserve the length of the array! Instead, parse holes as their own special AST node which prints invisibly. --- lib/parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/parse.js') diff --git a/lib/parse.js b/lib/parse.js index 5b6820ff..01fbb88f 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1131,7 +1131,7 @@ function parse($TEXT, options) { if (first) first = false; else expect(","); if (allow_trailing_comma && is("punc", closing)) break; if (is("punc", ",") && allow_empty) { - a.push(new AST_Undefined({ start: S.token, end: S.token })); + a.push(new AST_Hole({ start: S.token, end: S.token })); } else { a.push(expression(false)); } -- cgit v1.2.3