zod 4.2.0-canary.20250911T051312 → 4.2.0-canary.20250911T051520

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.2.0-canary.20250911T051312",
3
+ "version": "4.2.0-canary.20250911T051520",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -324,6 +324,14 @@ test("defaulted object schema returns shallow clone", () => {
324
324
  expect(result1).toEqual(result2);
325
325
  });
326
326
 
327
+ test("defaulted array schema returns shallow clone", () => {
328
+ const schema = z.array(z.string()).default(["x"]);
329
+ const result1 = schema.parse(undefined);
330
+ const result2 = schema.parse(undefined);
331
+ expect(result1).not.toBe(result2);
332
+ expect(result1).toEqual(result2);
333
+ });
334
+
327
335
  test("direction-aware defaults", () => {
328
336
  const schema = z.string().default("hello");
329
337
 
@@ -395,6 +395,7 @@ export function isPlainObject(o: any): o is Record<PropertyKey, unknown> {
395
395
 
396
396
  export function shallowClone(o: any): any {
397
397
  if (isPlainObject(o)) return { ...o };
398
+ if (Array.isArray(o)) return [...o];
398
399
  return o;
399
400
  }
400
401
 
package/v4/core/util.cjs CHANGED
@@ -228,6 +228,8 @@ function isPlainObject(o) {
228
228
  function shallowClone(o) {
229
229
  if (isPlainObject(o))
230
230
  return { ...o };
231
+ if (Array.isArray(o))
232
+ return [...o];
231
233
  return o;
232
234
  }
233
235
  function numKeys(data) {
package/v4/core/util.js CHANGED
@@ -173,6 +173,8 @@ export function isPlainObject(o) {
173
173
  export function shallowClone(o) {
174
174
  if (isPlainObject(o))
175
175
  return { ...o };
176
+ if (Array.isArray(o))
177
+ return [...o];
176
178
  return o;
177
179
  }
178
180
  export function numKeys(data) {