Commit 653c9353 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

DevTools: top level await rewrite should not change for of var decl

We can not replace it with our regular void (a = ...) here, so let's
just ignore it.

R=lushnikov@chromium.org

Bug: chromium:805249
Change-Id: I859ca107a15a0284a7c6a2ed0e32fe0c11d4734f
Reviewed-on: https://chromium-review.googlesource.com/1249539
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594816}
parent 3d3a3fd2
......@@ -116,4 +116,9 @@ var {a = await new Promise(resolve => resolve({a:123}))} = {a : 3}
was processed:
(async () => {void ({a = await new Promise(resolve => resolve({a:123}))} = {a : 3})
})()
--------------
await 1; for (var a of [1,2,3]);
was processed:
(async () => {await 1; for (var a of [1,2,3]);
})()
......@@ -24,7 +24,8 @@
'for await (const number of asyncRandomNumbers()) {}',
'[...(await fetch(\'url\', { method: \'HEAD\' })).headers.entries()]',
'await 1\n//hello',
'var {a = await new Promise(resolve => resolve({a:123}))} = {a : 3}'
'var {a = await new Promise(resolve => resolve({a:123}))} = {a : 3}',
'await 1; for (var a of [1,2,3]);'
];
await TestRunner.loadModule("formatter");
......
......@@ -195,6 +195,8 @@ FormatterWorker.preprocessTopLevelAwaitExpressions = function(content) {
VariableDeclaration(node) {
if (node.kind !== 'var' && node.parent !== body)
return;
if (node.parent.type === 'ForOfStatement' && node.parent.left === node)
return;
const onlyOneDeclaration = node.declarations.length === 1;
changes.push(
{text: onlyOneDeclaration ? 'void' : 'void (', start: node.start, end: node.start + node.kind.length});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment