tc39 / proposal-pattern-matching

Pattern matching syntax for ECMAScript
https://tc39.es/proposal-pattern-matching/
MIT License
5.51k stars 89 forks source link

README implies that regular expression literals are privileged over other instances #319

Closed gibson042 closed 2 months ago

gibson042 commented 8 months ago

(originally posted by @gibson042 in https://github.com/tc39/proposal-pattern-matching/pull/293#discussion_r1311844389)

https://github.com/tc39/proposal-pattern-matching#regex-patterns

A regex pattern is a regex literal, representing a test that the subject, when stringified, successfully matches the regex.

Is this privileging literals in such a way that when /.../ can act differently than when re after re = /.../ in an environment where primordials have been subject to arbitrary manipulation?

It does include clarifying text:

(Technically, this just invokes the RegExp.prototype[Symbol.customMatcher] method; that is, x is /foo/; and let re = /foo/; x is re; are identical in behavior wrt built-in fiddling.)

...but the initial sentence is still misleading.

The section's "Examples" block is also empty.

tabatkins commented 8 months ago

Given that the clarifying sentence is literally the next text in the README, I think that's sufficient for now?

(And yes, examples need to be filled in for multiple sections.)