Skip to content
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

Unexpected prop-missing error when destructuring an array #8921

Closed
Robloche opened this issue Aug 22, 2022 · 2 comments
Closed

Unexpected prop-missing error when destructuring an array #8921

Robloche opened this issue Aug 22, 2022 · 2 comments

Comments

@Robloche
Copy link

Try these lines:

const arr = [{foo: 42}, {foo: 17}];
const index = 1;
const {[index]: {foo}} = arr;

As you can see here, no error is reported until v0.184 but v0.185+ raises a prop-missing error.

It is worthy to note that replacing index by a number works in v0.185:

const arr = [{foo: 42}, {foo: 17}];
const {[1]: {foo}} = arr;
@Robloche
Copy link
Author

The same issue arises when destructuring objects:

const obj = {foo: {bar: 42}};
const key = 'foo';
const {[key]: {bar}} = obj;

Try it here.

@panagosg7
Copy link
Contributor

Thanks for the report and the repros @Robloche !

This surfaced as an issue in 0.185 since we turned on inference_mode=constrain_writes by default.

I have identified the root cause and I am preparing a fix. Hopefully, it will be included in 0.186.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants