Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 5bfb9bf

Browse files
JamesHenrynzakas
authored andcommitted
Fix: Check for arguments property on NewExpression (fixes #60) (#62)
1 parent d323ee7 commit 5bfb9bf

File tree

3 files changed

+296
-1
lines changed

3 files changed

+296
-1
lines changed

lib/ast-converter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ module.exports = function(ast, extra) {
15331533
assign(result, {
15341534
type: "NewExpression",
15351535
callee: convertChild(node.expression),
1536-
arguments: node.arguments.map(convertChild)
1536+
arguments: (node.arguments) ? node.arguments.map(convertChild) : []
15371537
});
15381538
}
15391539
break;
Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
module.exports = {
2+
"type": "Program",
3+
"loc": {
4+
"start": {
5+
"line": 1,
6+
"column": 0
7+
},
8+
"end": {
9+
"line": 2,
10+
"column": 6
11+
}
12+
},
13+
"range": [
14+
0,
15+
23
16+
],
17+
"body": [
18+
{
19+
"type": "FunctionDeclaration",
20+
"loc": {
21+
"start": {
22+
"line": 1,
23+
"column": 0
24+
},
25+
"end": {
26+
"line": 1,
27+
"column": 16
28+
}
29+
},
30+
"range": [
31+
0,
32+
16
33+
],
34+
"id": {
35+
"type": "Identifier",
36+
"loc": {
37+
"start": {
38+
"line": 1,
39+
"column": 9
40+
},
41+
"end": {
42+
"line": 1,
43+
"column": 10
44+
}
45+
},
46+
"range": [
47+
9,
48+
10
49+
],
50+
"name": "X"
51+
},
52+
"generator": false,
53+
"expression": false,
54+
"params": [],
55+
"body": {
56+
"type": "BlockStatement",
57+
"loc": {
58+
"start": {
59+
"line": 1,
60+
"column": 14
61+
},
62+
"end": {
63+
"line": 1,
64+
"column": 16
65+
}
66+
},
67+
"range": [
68+
14,
69+
16
70+
],
71+
"body": []
72+
}
73+
},
74+
{
75+
"type": "ExpressionStatement",
76+
"loc": {
77+
"start": {
78+
"line": 2,
79+
"column": 0
80+
},
81+
"end": {
82+
"line": 2,
83+
"column": 6
84+
}
85+
},
86+
"range": [
87+
17,
88+
23
89+
],
90+
"expression": {
91+
"type": "NewExpression",
92+
"loc": {
93+
"start": {
94+
"line": 2,
95+
"column": 0
96+
},
97+
"end": {
98+
"line": 2,
99+
"column": 5
100+
}
101+
},
102+
"range": [
103+
17,
104+
22
105+
],
106+
"callee": {
107+
"type": "Identifier",
108+
"loc": {
109+
"start": {
110+
"line": 2,
111+
"column": 4
112+
},
113+
"end": {
114+
"line": 2,
115+
"column": 5
116+
}
117+
},
118+
"range": [
119+
21,
120+
22
121+
],
122+
"name": "X"
123+
},
124+
"arguments": []
125+
}
126+
}
127+
],
128+
"sourceType": "script",
129+
"tokens": [
130+
{
131+
"type": "Keyword",
132+
"value": "function",
133+
"loc": {
134+
"start": {
135+
"line": 1,
136+
"column": 0
137+
},
138+
"end": {
139+
"line": 1,
140+
"column": 8
141+
}
142+
},
143+
"range": [
144+
0,
145+
8
146+
]
147+
},
148+
{
149+
"type": "Identifier",
150+
"value": "X",
151+
"loc": {
152+
"start": {
153+
"line": 1,
154+
"column": 9
155+
},
156+
"end": {
157+
"line": 1,
158+
"column": 10
159+
}
160+
},
161+
"range": [
162+
9,
163+
10
164+
]
165+
},
166+
{
167+
"type": "Punctuator",
168+
"value": "(",
169+
"loc": {
170+
"start": {
171+
"line": 1,
172+
"column": 11
173+
},
174+
"end": {
175+
"line": 1,
176+
"column": 12
177+
}
178+
},
179+
"range": [
180+
11,
181+
12
182+
]
183+
},
184+
{
185+
"type": "Punctuator",
186+
"value": ")",
187+
"loc": {
188+
"start": {
189+
"line": 1,
190+
"column": 12
191+
},
192+
"end": {
193+
"line": 1,
194+
"column": 13
195+
}
196+
},
197+
"range": [
198+
12,
199+
13
200+
]
201+
},
202+
{
203+
"type": "Punctuator",
204+
"value": "{",
205+
"loc": {
206+
"start": {
207+
"line": 1,
208+
"column": 14
209+
},
210+
"end": {
211+
"line": 1,
212+
"column": 15
213+
}
214+
},
215+
"range": [
216+
14,
217+
15
218+
]
219+
},
220+
{
221+
"type": "Punctuator",
222+
"value": "}",
223+
"loc": {
224+
"start": {
225+
"line": 1,
226+
"column": 15
227+
},
228+
"end": {
229+
"line": 1,
230+
"column": 16
231+
}
232+
},
233+
"range": [
234+
15,
235+
16
236+
]
237+
},
238+
{
239+
"type": "Keyword",
240+
"value": "new",
241+
"loc": {
242+
"start": {
243+
"line": 2,
244+
"column": 0
245+
},
246+
"end": {
247+
"line": 2,
248+
"column": 3
249+
}
250+
},
251+
"range": [
252+
17,
253+
20
254+
]
255+
},
256+
{
257+
"type": "Identifier",
258+
"value": "X",
259+
"loc": {
260+
"start": {
261+
"line": 2,
262+
"column": 4
263+
},
264+
"end": {
265+
"line": 2,
266+
"column": 5
267+
}
268+
},
269+
"range": [
270+
21,
271+
22
272+
]
273+
},
274+
{
275+
"type": "Punctuator",
276+
"value": ";",
277+
"loc": {
278+
"start": {
279+
"line": 2,
280+
"column": 5
281+
},
282+
"end": {
283+
"line": 2,
284+
"column": 6
285+
}
286+
},
287+
"range": [
288+
22,
289+
23
290+
]
291+
}
292+
]
293+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function X () {}
2+
new X;

0 commit comments

Comments
 (0)