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

v-for compiler error case #5819

Closed
hchlq opened this issue Apr 28, 2022 · 3 comments · Fixed by #5821
Closed

v-for compiler error case #5819

hchlq opened this issue Apr 28, 2022 · 3 comments · Fixed by #5821
Labels
has PR A pull request has already been submitted to solve the issue 🔩 p2-edge-case scope: compiler ✨ feature request New feature or request

Comments

@hchlq
Copy link
Contributor

hchlq commented Apr 28, 2022

Version

3.2.33

Reproduction link

sfc.vuejs.org/

Steps to reproduce

v-for only spaces after in or of

What is expected?

in this case, should report an X_V_FOR_MALFORMED_EXPRESSION error during compiler

What is actually happening?

error reporting during runtime. (Unexpected token ','. )

@hchlq
Copy link
Contributor Author

hchlq commented Apr 28, 2022

Personally, I think the forAliasRE can be changed

// origin
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/

// suggestion
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([^\s]+)/

@edison1105
Copy link
Member

@hchlq PR welcome.

@hunyan-io
Copy link

Personally, I think the forAliasRE can be changed

// origin
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/

// suggestion
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([^\s]+)/

I think this causes issues with expressions that contain spaces after in/of. You can try with v-for="item in store . items" . This might be a good test case to add.
I think the following regex fixes the issue const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/

@haoqunjiang haoqunjiang added the has PR A pull request has already been submitted to solve the issue label Aug 31, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has PR A pull request has already been submitted to solve the issue 🔩 p2-edge-case scope: compiler ✨ feature request New feature or request
Projects
None yet
5 participants