swiftlang / swiftlang/swift-experimental-string-processing

Regex literals with invalid `\N{...}` names should not compile

Open
#270 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
308
Forks
52
Avg merge
12h 45m
Merged PRs (30d)
2

Description

UTS18 makes a distinction between providing an invalid name in a Unicode property character class (\p{name=...}) and an individual named character (\N{...}). If a programmer uses an invalid name in a property character class, the expression should compile and that character class should simply not match anything:

"🐯".contains(/\p{name=TIGER FACE}/)     // true
"🐯".contains(/\p{name=TIEGR FACE}/)     // false

However, an invalid name given in a \N{...} named character should be a syntax/compilation error:

"🐯".contains(/\N{TIEGR FACE}/)          // error: Invalid Unicode scalar name

See https://unicode.org/reports/tr18/#Individually_Named_Characters

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the regex engine parses and validates \N{...} names, then compare that behavior with the documented \p{name=...} handling in UTS18. Done means an invalid name in \N{...} is rejected as a compilation error, while an invalid property name remains compilable and matches nothing.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.