swiftlang / swift-experimental-string-processing

An early experimental general-purpose pattern matching engine for Swift.
Apache License 2.0
278 stars 47 forks source link

Regex non-deterministicly fails #639

Open jasonbobier opened 1 year ago

jasonbobier commented 1 year ago

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

Mac.playground.zip

hamishknight commented 1 year ago

cc @natecook1000

jasonbobier commented 1 year ago

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 commented 1 year ago

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 commented 7 months ago

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