Open cyisfor opened 6 years ago
Yeah, Regenerator expects destructuring syntax to have been compiled earlier in the pipeline. Implementing special logic for destructuring in Regenerator itself would fix this problem, but I don't think there are any JS engines that natively support destructuring but not generator functions, so you should either be compiling both destructuring and generators (in that order), or neither.
Hi @benjamn is this issue related to https://github.com/facebook/regenerator/issues/391
async function foo(bar) { let [key,value] = [2, 3]; }
=>
Error while reading module test: TypeError: unknown: Cannot read property '0' of null at isHelper (/somewhere/regenerator/node_modules/babel-generator/lib/node/whitespace.js:40:48) at VariableDeclaration (/somewhere/regenerator/node_modules/babel-generator/lib/node/whitespace.js:95:21) at find (/somewhere/regenerator/node_modules/babel-generator/lib/node/index.js:93:15) at needsWhitespace (/somewhere/regenerator/node_modules/babel-generator/lib/node/index.js:115:19) at needsWhitespaceBefore (/somewhere/regenerator/node_modules/babel-generator/lib/node/index.js:131:10) at Generator._printNewline (/somewhere/regenerator/node_modules/babel-generator/lib/printer.js:467:11) at Generator.printJoin (/somewhere/regenerator/node_modules/babel-generator/lib/printer.js:364:32) at Generator.printSequence (/somewhere/regenerator/node_modules/babel-generator/lib/printer.js:420:17) at Generator.BlockStatement (/somewhere/regenerator/node_modules/babel-generator/lib/generators/base.js:43:10) at /somewhere/regenerator/node_modules/babel-generator/lib/printer.js:298:23 From previous event: at buildP (/somewhere/regenerator/node_modules/commoner/lib/reader.js:167:16) at /somewhere/regenerator/node_modules/commoner/lib/reader.js:195:28 From previous event: at ModuleReader. (/somewhere/regenerator/node_modules/commoner/lib/reader.js:97:38)
at ModuleReader.wrapper [as readModuleP] (/somewhere/regenerator/node_modules/commoner/lib/util.js:53:31)
at Array.map (native)
at /somewhere/regenerator/node_modules/commoner/lib/reader.js:231:32
From previous event:
at rebuild (/somewhere/regenerator/node_modules/commoner/lib/commoner.js:135:14)
at _combinedTickCallback (internal/process/next_tick.js:95:7)
async function foo(bar) { let key = 2; let value = 3; }
=> no error