Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex non-deterministicly fails #639

Open
jasonbobier opened this issue Mar 5, 2023 · 4 comments
Open

Regex non-deterministicly fails #639

jasonbobier opened this issue Mar 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@jasonbobier
Copy link

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

@jasonbobier jasonbobier added the bug Something isn't working label Mar 5, 2023
@hamishknight hamishknight transferred this issue from apple/swift Mar 6, 2023
@hamishknight
Copy link
Contributor

cc @natecook1000

@jasonbobier
Copy link
Author

The playground in Xcode Version 15.0 beta (15A5160n) produces:

expression failed to parse:
error: Couldn't lookup symbols:
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>

@jasonbobier
Copy link
Author

The playground in Xcode Version 15.0 beta (15A5160n) produces:

expression failed to parse:
error: Couldn't lookup symbols:
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>
  _StringProcessing._RegexFactory.ignoreCapturesInTypedOutput<τ_0_0 where τ_0_0: _StringProcessing.RegexComponent>(τ_0_0) -> _StringProcessing.Regex<Swift.Substring>

Still seeing this error in Xcode 15 final.

@jasonbobier
Copy link
Author

@natecook1000 can you comment on this? It has been over a year and I still get a non-deterministic failure with this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants