New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: BABEL_PARSE_ERROR regarding duplicate function definitions #16303
Comments
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. |
Please check if the source code type is set to |
Thank you for your answer. After checking, I found that the code is not in strict mode, maybe there are other reasons. |
Can you add |
馃捇
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: