Skip to content

Add missing String.count/2 clause for empty pattern list#15342

Merged
josevalim merged 2 commits intoelixir-lang:mainfrom
lukaszsamson:ls-string-count-empty
May 6, 2026
Merged

Add missing String.count/2 clause for empty pattern list#15342
josevalim merged 2 commits intoelixir-lang:mainfrom
lukaszsamson:ls-string-count-empty

Conversation

@lukaszsamson
Copy link
Copy Markdown
Contributor

Pattern is defined as:

  @typedoc """
  Pattern used in functions like `replace/4` and `split/3`.

  It must be one of:

    * a string
    * an empty list
    * a list containing non-empty strings
    * a compiled search pattern created by `:binary.compile_pattern/1`

  """
  @type pattern ::
          t()
          | [nonempty_binary]
          | (compiled_search_pattern :: :binary.cp())

other functions like split/3, replace/4, contains?/2 have special cases for empty list

lukaszsamson and others added 2 commits May 5, 2026 22:20
Updated documentation to reflect that the pattern can be a list, including examples.
@josevalim josevalim merged commit 16f5174 into elixir-lang:main May 6, 2026
15 checks passed
@josevalim
Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants