-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix(compiler-sfc): add error handling for defineModel() without variable assignment #13352
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA validation was added to enforce that Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Compiler
participant ErrorReporter
User->>Compiler: Call defineModel()
alt Not assigned to variable
Compiler->>ErrorReporter: Report error ("defineModel() must be assigned...")
else Assigned to variable
Compiler->>Compiler: Continue processing defineModel()
end
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-ssr
@vue/compiler-sfc
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
export enum DOMErrorCodes {
X_V_HTML_NO_EXPRESSION = 53 /* ErrorCodes.__EXTEND_POINT__ */,
|
@edison1105 I have updated it for testing but forgot to commit. I will commit this change soon. Thank you so much. |
@runyasak |
@edison1105 I apologize for not running all the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/compiler-sfc/__tests__/compileScript.spec.ts (1)
982-984
: Missing space after the equals signThere should be a space between
=
anddefineModel
for consistent code style.- const model =defineModel({ + const model = defineModel({ default: () => bar
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
packages/compiler-sfc/__tests__/compileScript.spec.ts
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
🔇 Additional comments (3)
packages/compiler-sfc/__tests__/compileScript.spec.ts (3)
982-986
: LGTM: Good test case for variable reference restrictionThis test correctly validates that
defineModel()
with locally declaredlet
variables in the default function will throw an error, while ensuringdefineModel()
is assigned to a variable.
992-996
: LGTM: Good test case for const variablesThis test correctly verifies that using
const
variables indefineModel()
is allowed, while ensuring proper variable assignment.
1002-1007
: LGTM: Good test case for get/set handlersThis test correctly verifies that using
let
variables indefineModel()
is allowed when they're used within get/set handlers, while ensuring proper variable assignment.
@edison1105 Oh, I forgot a space. 😂 |
LGTM~ |
@edison1105 @KazariEX Thank you so much for helping me. 😁 |
packages/compiler-dom/src/errors.ts
Outdated
@@ -21,7 +21,7 @@ export function createDOMCompilerError( | |||
} | |||
|
|||
export enum DOMErrorCodes { | |||
X_V_HTML_NO_EXPRESSION = 53 /* ErrorCodes.__EXTEND_POINT__ */, | |||
X_V_HTML_NO_EXPRESSION = 54 /* ErrorCodes.__EXTEND_POINT__ */, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking change here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I update anything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. 😁
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Fixes #13280
Overview
I added validation to ensure
defineModel()
is always assigned to a variable, throwing an error message if used incorrectly.Scope of work
add verified error message:
defineModel() must be assigned to a variable
Screenshots
If you have any feedback or suggestions, please let me know and I will update the code accordingly.
Summary by CodeRabbit
Bug Fixes
defineModel()
is not assigned to a variable, with a clear error message.Tests
defineModel()
must be assigned to a variable.defineModel()
to a variable.Chores