-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix shape caching #5263
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
Fix shape caching #5263
Conversation
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.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on October 3
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| util.assignProp(this, "shape", shape ? util.objectClone(shape) : {}); | ||
| return this.shape; | ||
| }, | ||
| shape: shape!, |
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.
Bug: Object Function Shape Parameter Non-Null Assertion Bug
The object function's shape parameter is optional, but the new code uses a non-null assertion (shape!) for assignment. This assigns undefined to def.shape when no shape is provided, unlike the previous getter which defaulted to an empty object. This affects both mini and classic schemas and could cause runtime errors.
Additional Locations (1)
| $ZodType.init(inst, def); | ||
| // const sh = def.shape; | ||
| const desc = Object.getOwnPropertyDescriptor(def, "shape"); | ||
| if (!desc!.get) { |
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.
Fixes #5241