Fix stateful Schema.isPattern validation - #6712
Conversation
🦋 Changeset detectedLatest commit: 1281480 The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
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 |
📝 WalkthroughWalkthrough
ChangesSchema pattern state
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/effect/test/schema/Schema.test.ts (1)
1250-1257: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAlso test a pre-existing non-zero
lastIndex.Initialize each expression with
lastIndex = 1before decoding and assert it remains1. This verifies both that validation starts from zero and that caller-owned RegExp state is preserved.Proposed test adjustment
for (const regExp of [/^a/g, /^a/y]) { + regExp.lastIndex = 1 const schema = Schema.String.check(Schema.isPattern(regExp)) const decoding = new TestSchema.Asserts(schema).decoding() await decoding.succeed("a") await decoding.succeed("a") - strictEqual(regExp.lastIndex, 0) + strictEqual(regExp.lastIndex, 1) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/effect/test/schema/Schema.test.ts` around lines 1250 - 1257, Update the “isPattern with stateful RegExp flags” test to set each RegExp’s lastIndex to 1 before decoding, then assert it remains 1 after validation. Preserve the existing repeated decoding assertions for both global and sticky expressions, verifying validation resets its working position without mutating caller-owned RegExp state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/effect/test/schema/Schema.test.ts`:
- Around line 1250-1257: Update the “isPattern with stateful RegExp flags” test
to set each RegExp’s lastIndex to 1 before decoding, then assert it remains 1
after validation. Preserve the existing repeated decoding assertions for both
global and sticky expressions, verifying validation resets its working position
without mutating caller-owned RegExp state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: efeaa7d8-7117-43d5-8eb0-223c8f12ce3a
📒 Files selected for processing (3)
.changeset/fix-schema-pattern-state.mdpackages/effect/src/SchemaAST.tspackages/effect/test/schema/Schema.test.ts
Bundle Size Analysis
|
Summary by CodeRabbit