Skip to content

non-greedy matching for Schema.String in Schema.TemplateLiteralParser#5322

Merged
gcanti merged 2 commits intoEffect-TS:mainfrom
beezee:non-greedy-templateliteral-strings
Aug 3, 2025
Merged

non-greedy matching for Schema.String in Schema.TemplateLiteralParser#5322
gcanti merged 2 commits intoEffect-TS:mainfrom
beezee:non-greedy-templateliteral-strings

Conversation

@beezee
Copy link
Copy Markdown
Contributor

@beezee beezee commented Aug 3, 2025

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR changes the regex used for Schema.String in TemplateLiteralParser from greedy to non-greedy ([\\s\\S]* -> [\\s\\S]*?). Greedy matching can consume too much input and prevent following spans from matching. The non-greedy version allows downstream segments to parse correctly.

Minimal repro is shown in this playground: https://effect.website/play#a54077a17e06

Note the minimal repro avoids NumberFromString (case exercised in the added test) to avoid unsupported span error when extracting the regex via TemplateLiteral.

Related

This was discussed briefly here: https://discord.com/channels/795981131316985866/1344319931625246770

@beezee
Copy link
Copy Markdown
Contributor Author

beezee commented Aug 3, 2025

@gcanti my mistake, I clearly missed some tests! Updating now...

@gcanti
Copy link
Copy Markdown
Contributor

gcanti commented Aug 3, 2025

@beezee no problem, great fix, I have already applied it in v4

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Aug 3, 2025

🦋 Changeset detected

Latest commit: 2248b1e

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

This PR includes changesets to release 35 packages
Name Type
effect Patch
@effect/cli Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/platform Patch
@effect/printer-ansi Patch
@effect/printer Patch
@effect/rpc Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-drizzle Patch
@effect/sql-kysely Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg 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/sql Patch
@effect/typeclass Patch
@effect/vitest Patch
@effect/workflow Patch
@effect/ai Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-google Patch
@effect/ai-openai 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

@gcanti gcanti merged commit f187941 into Effect-TS:main Aug 3, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Aug 3, 2025
@github-actions github-actions bot mentioned this pull request Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants