swiftlang / swiftlang/swift-experimental-string-processing

Regex non-deterministicly fails

Open
#639 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
Please see the attached playground. The regex in it will work sometimes and fail other times over the same data set. It fails because it isn't greedily consuming a ZeroOrMore.

Steps to reproduce
Open the enclosed playground. Keep changing portions (to cause a recompile) until it fails.

Expected behavior
The ZeroOrMores should consume the entire matching string in the whole match. Also, the same string processed by the same regex should always either fail or not fail.

Environment

  • Swift compiler version info: swift-driver version
    1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
    Target: arm64-apple-macosx13.0

  • Xcode version info:
    Xcode 14.2
    Build version 14C18

Mac.playground.zip

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

Open the attached Mac.playground.zip and reproduce the behavior by repeatedly changing portions to trigger recompilation with the same data set. Investigate why ZeroOrMore does not consistently consume the entire matching string; done means identical input and regex always produce the same result and the whole match consumes the expected string.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.