You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function* countDown(begin) {
while (begin >= 0) {
yield begin--;
}
}
var begin;
function* func1() {
yield 'aha';
yield 'ihi';
yield 'uhu';
}
for (const e of func1())
for (const e of countDown(10)) {
console.log(e);
}
function* countDown(begin) {
while (begin >= 0) {
yield begin--;
}
}
for (const e of countDown(10)) {
console.log(e);
I am using babel to run the code,and here is the error reported:Syntax error,Identifier "CountDown" has already been declared.
To my knowledge, in JavaScript, when a function is declared repeatedly, the function declaration defined later will overwrite the previous function declaration. Therefore, I believe that the code I provided is grammatically compliant, but Babel refuses to translate this code. Is this because Babel believes there is a syntax error in this code? Please explain this issue to me, thank you
Hey @Roise-yue! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
馃捇
How are you using Babel?
@babel/cli
Input code
function* countDown(begin) {
while (begin >= 0) {
yield begin--;
}
}
var begin;
function* func1() {
yield 'aha';
yield 'ihi';
yield 'uhu';
}
for (const e of func1())
for (const e of countDown(10)) {
console.log(e);
}
function* countDown(begin) {
while (begin >= 0) {
yield begin--;
}
}
for (const e of countDown(10)) {
console.log(e);
}
Configuration file name
.babelrc
Configuration
{
"presets": ["@babel/preset-env"],
"plugins": []
}
Current and expected behavior
I am using babel to run the code,and here is the error reported:Syntax error,Identifier "CountDown" has already been declared.
To my knowledge, in JavaScript, when a function is declared repeatedly, the function declaration defined later will overwrite the previous function declaration. Therefore, I believe that the code I provided is grammatically compliant, but Babel refuses to translate this code. Is this because Babel believes there is a syntax error in this code? Please explain this issue to me, thank you
Environment
Babel:v7.23.9
node.js : v21.6.1
npm: v10.2.4
Ubuntu: v20.04
Possible solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: