Skip to content
Prev Previous commit
Next Next commit
add double declaration test case
  • Loading branch information
GeoffreyBooth committed Mar 11, 2024
commit 7f99f57bd373ecf211bdfba6eb0ca15c036908c2
13 changes: 13 additions & 0 deletions test/es-module/test-esm-detect-ambiguous.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
strictEqual(code, 0);
strictEqual(signal, null);
});

it('still throws on double `const` declaration not at the top level', async () => {
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
'--experimental-detect-module',
'--eval',
'function fn() { const require = 1; const require = 2; } fn();',
]);

match(stderr, /SyntaxError: Identifier 'require' has already been declared/);
strictEqual(stdout, '');
strictEqual(code, 1);
strictEqual(signal, null);
});
});
});

Expand Down