Check symbol-keyed properties in Match object patterns - #6947
Conversation
|
There was a problem hiding this comment.
Important
This PR reproduces the symbol-keyed object pattern bug with a focused regression test, but the implementation fix in packages/effect/src/internal/matcher.ts is still missing. CI will continue to fail until the fix is included.
Reviewed changes
packages/effect/test/Match.test.ts: adds a regression test demonstrating that an object pattern with only a symbol key wrongly matches a value where the symbol property does not satisfy the constraint.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
| Match.orElse(() => "miss") | ||
| ) | ||
|
|
||
| strictEqual(match({ [key]: "other" }), "miss") |
There was a problem hiding this comment.
The test only exercises the wrong-value path. Consider also asserting that { [key]: "expected" } matches ("hit") and that {} returns "miss", matching the hit/miss coverage of the neighboring tests and reducing the chance that an incomplete fix passes accidentally.

Summary
A valid typed object pattern whose only key is a symbol compiles as an empty conjunction and matches non-null objects that do not satisfy the symbol property's constraint.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Symbol-keyed object patterns match without checking the symbol
Module:
MatchAudit ID:
core-g-r-match-symbol-key-pattern-omittedSeverity / confidence: medium / high
What happens
A valid typed object pattern whose only key is a symbol compiles as an empty conjunction and matches non-null objects that do not satisfy the symbol property's constraint.
Why it happens
The runtime compiler enumerates pattern properties with Object.entries, which omits symbols. A symbol-only pattern therefore has no compiled predicates and accepts the wrong value.
Expected behavior
Types.PatternBase maps every key of a record-shaped value, including symbol keys, and a successful object-pattern match satisfies every supplied property constraint.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/Match.ts:2234-2238packages/effect/src/internal/matcher.ts:126-145View problematic code at
packages/effect/src/Match.ts:2234-2238View exact lines on GitHub
View problematic code at
packages/effect/src/internal/matcher.ts:126-145View exact lines on GitHub
Reproduction
pnpm vitest run packages/effect/test/Match.test.ts -t "checks symbol-keyed object pattern properties"Observed failure: The intended failure was reproduced: the matcher returned "hit" instead of "miss".
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm vitest run packages/effect/test/Match.test.ts -t "checks symbol-keyed object pattern properties"Audit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fcore-g-r-match-symbol-key-pattern-omitted