Skip to content

Preserve nested class construction when applying constructor defaults, closes #6491#6492

Merged
gcanti merged 1 commit into
mainfrom
fix-6491
Jul 19, 2026
Merged

Preserve nested class construction when applying constructor defaults, closes #6491#6492
gcanti merged 1 commit into
mainfrom
fix-6491

Conversation

@gcanti

@gcanti gcanti commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Preserved nested class construction when applying constructor defaults.
    • Schema fields with constructor defaults now correctly produce class instances from plain object input.
  • Tests

    • Added coverage for constructing nested schema classes with default values.

@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 720d5e7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 7e13e04b-bddd-4df7-9c66-726388e5c453

📥 Commits

Reviewing files that changed from the base of the PR and between ce95d88 and 720d5e7.

📒 Files selected for processing (3)
  • .changeset/fix-6491.md
  • packages/effect/src/SchemaParser.ts
  • packages/effect/test/schema/Schema.test.ts

📝 Walkthrough

Walkthrough

Updates schema constructor AST handling so nested Schema.Class values remain constructible when constructor defaults are applied. Adds a regression test and a patch changeset.

Changes

Constructor defaults

Layer / File(s) Summary
Constructor AST restoration and regression coverage
packages/effect/src/SchemaParser.ts, packages/effect/test/schema/Schema.test.ts, .changeset/fix-6491.md
Replaces recursive default handling with constructor-aware AST conversion, preserves nested class construction for object and array nodes, adds a regression test, and records a patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: bug, 4.0

Suggested reviewers: tim-smart

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preserving nested class construction when applying constructor defaults.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added 4.0 bug Something isn't working labels Jul 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.66 KB 6.66 KB 0.00 KB (0.00%)
batching.ts 9.26 KB 9.26 KB 0.00 KB (0.00%)
brand.ts 6.14 KB 6.14 KB 0.00 KB (0.00%)
cache.ts 9.90 KB 9.90 KB 0.00 KB (0.00%)
config.ts 18.88 KB 18.87 KB +0.01 KB (+0.07%)
differ.ts 17.10 KB 17.09 KB +0.01 KB (+0.08%)
http-client.ts 20.58 KB 20.58 KB 0.00 KB (0.00%)
logger.ts 10.25 KB 10.25 KB 0.00 KB (0.00%)
metric.ts 8.52 KB 8.52 KB 0.00 KB (0.00%)
optic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
pubsub.ts 14.09 KB 14.09 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.29 KB 10.29 KB 0.00 KB (0.00%)
schema-class.ts 17.95 KB 17.95 KB +0.01 KB (+0.04%)
schema-fromJsonSchemaDocument.ts 4.06 KB 4.06 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.33 KB 27.31 KB +0.02 KB (+0.06%)
schema-string-transformation.ts 12.62 KB 12.61 KB +0.01 KB (+0.07%)
schema-string.ts 10.29 KB 10.27 KB +0.03 KB (+0.24%)
schema-template-literal.ts 14.26 KB 14.25 KB +0.01 KB (+0.06%)
schema-toArbitraryLazy.ts 20.73 KB 20.72 KB +0.01 KB (+0.04%)
schema-toCodeDocument.ts 21.31 KB 21.30 KB +0.01 KB (+0.03%)
schema-toCodecJson.ts 17.92 KB 17.92 KB +0.01 KB (+0.04%)
schema-toEquivalence.ts 17.81 KB 17.81 KB +0.01 KB (+0.04%)
schema-toFormatter.ts 17.64 KB 17.64 KB +0.01 KB (+0.03%)
schema-toJsonSchemaDocument.ts 20.21 KB 20.20 KB +0.01 KB (+0.03%)
schema-toRepresentation.ts 18.20 KB 18.19 KB +0.01 KB (+0.04%)
schema.ts 17.23 KB 17.22 KB +0.01 KB (+0.04%)
stm.ts 12.02 KB 12.02 KB 0.00 KB (0.00%)
stream.ts 9.29 KB 9.29 KB 0.00 KB (0.00%)

@gcanti
gcanti merged commit 6dc83f2 into main Jul 19, 2026
15 checks passed
@gcanti
gcanti deleted the fix-6491 branch July 19, 2026 18:26
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 19, 2026
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Schema: recurDefaults replaces a constructor-defaulted class field's encoding

1 participant