-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
compiler-sfc: invalid declaration while using multiple variables with defineEmits
and defineProps
#7422
Labels
Comments
@mnixry PR welcome. |
mnixry
added a commit
to mnixry/nonebot-plugin-gocqhttp
that referenced
this issue
Dec 30, 2022
sxzz
added a commit
that referenced
this issue
Jan 26, 2023
sxzz
added a commit
that referenced
this issue
Feb 4, 2023
haoqunjiang
added
has PR
A pull request has already been submitted to solve the issue
scope: compiler
labels
Mar 20, 2023
sxzz
added a commit
that referenced
this issue
Mar 27, 2023
sxzz
added a commit
that referenced
this issue
Mar 28, 2023
IAmSSH
pushed a commit
to IAmSSH/core
that referenced
this issue
May 14, 2023
…me declaration (vuejs#7423) closes vuejs#7422 reverts vuejs#6778
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Vue version
3.2.45
Link to minimal reproduction
https://sfc.vuejs.org/#eNqlkMFuwjAQRH/F8gWQcFykigMEpB567wf4EpINuIrt1doJQlH+vesArdQe69u8WXvGO8o3xGLoQe5kGWuymESE1OPReOswUBKjIGjFJFoKTix4dGF8HXxMwsWzOGR3udo/GVLAyLSB1nr4yGq5Whsv5gPOph/3PSt2hdan50TF7ksm9ZOcMtkzaYwv9b0jt2ORwGFXJWAlRHnZHMdx7jRNpWY1U+uxT2JQLjTQHYxk30i2Sv19W67l/avKVVh8xuB5GWO+bR5GNHInZpIZryBrIy8pYdxxMcAu3BQSDBauavu63SjFUyq2teKM25lC75vCQ+pseysqRM12Qb1P1kEB0akThWsE4ngjH+uakzTDAUgR+AYI6P/Jvx78k57DJ+MnOX0Byzq2CA==
Steps to reproduce
Define a set of variable with multiple declarations in SFC with
<script setup>
:It will lead to wrong transpile result:
What is expected?
It should be compiled into:
Without any syntax error.
What is actually happening?
This bug is introduced in #6778, compiler-sfc fixed a bug #6757, which is also related to multiple variable declaration.
Can reproduce in #6778's sfc-playgroound preview, but works perfectly in #6777 and older version.
Briefly, it occurs while we're processing a macro token with
define*
, with the following steps:core/packages/compiler-sfc/src/compileScript.ts
Lines 1222 to 1228 in c6e5bda
We can notice that, if the declaration is the last macro but not the last variable declaration, it will keep the redundant part of the declaration, which leads to the final syntax error.
To fix this issue, we can make the characters between the beginning of current and begin of next (if have) are unconditionally removed:
I will submit a PR trying to fix that if you like this solution.
System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: