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

Ref sugar compile result incorrect with destructuring + arrow function expression #3581

Closed
johnsoncodehk opened this issue Apr 10, 2021 · 3 comments · Fixed by #3582
Closed
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: script-setup scope: sfc

Comments

@johnsoncodehk
Copy link
Member

Version

3.0.11

Reproduction link

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbnJlZjogKHt9ID0gKCkgPT4gMSk7XG5yZWY6ICh7fSA9IHVzZVNvbXRoaW5nKCgpID0+IDEpKTtcbnJlZjogKHt9ID0gdXNlU29tdGhpbmcoY29tcHV0ZWQoKCkgPT4gMSkpKTtcbjwvc2NyaXB0PiJ9

Steps to reproduce

Check the JS compile result.

What is expected?

Result is:

const {} = (() => 1);
const {} = useSomthing((() => 1));
const {} = useSomthing(computed((() => 1)));

What is actually happening?

Result is:

const {} = ( => 1);
const {} = useSomthing(( => 1));
const {} = useSomthing(computed(( => 1)));
@HcySunYang HcySunYang added 🐞 bug Something isn't working 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Apr 10, 2021
@ygj6
Copy link
Member

ygj6 commented Apr 10, 2021

@johnsoncodehk Assigning a value to {} is not a wise choice, because {}==={} returns false and you will never be able to use the {} you defined.
But I think in this case, it would be better to report an exception when compiling.

@johnsoncodehk
Copy link
Member Author

@ygj6 this is just to show the problem, I use something like ref: ({ foo } = useSomthing(...)) in real code, thanks.

@edison1105
Copy link
Member

Oh~~ I did see @HcySunYang 's PR.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: script-setup scope: sfc
Projects
None yet
5 participants