-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: path.evaluate should not be confident about array literal variable initializer #14197
Comments
Hey @ef4! 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. |
This is broken for object literals too. If you substitute: function example() {
let value = { a: 1 };
value.a = 2;
return value;
}
|
If the initial length of the array is 0 then it should return |
You can be confident only if there are no other references to the binding in between initialization and return: function() {
let value = { a: 1 };
return value; // confident
}
function() {
let value = { a: 2 };
anythingThatUses(value);
return value; // not confident
} |
I'd like to work on this issue? |
Can I work on this Issue? |
💻
How are you using Babel?
Programmatic API (
babel.transform
,babel.parse
)Input code
This is a complete standalone reproduction:
Configuration file name
No response
Configuration
No response
Current and expected behavior
The assertion in my repro program above fails, because Babel believes it can statically evaluate the value of the return statement.
path.evaluate()
returns{ confident: true, depot: null, value: [] }
.Instead, it should return
{ confident: false }
, because it's not possible to statically determine the return value of this code snippet.Environment
Tested against
@babel/core
7.16.12 in Node 16.Possible solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: