k-takata/Onigmo

Absence operator is broken

kkos opened this issue · 2 comments

kkos commented
p /(?~ab)/.match("abc")
p /(?~abc)/.match("abc")
p /(?~ab|abc)/.match("abc")
=>
#<MatchData "a">
#<MatchData "ab">
#<MatchData "a">

But

p /(?~abc|ab)/.match("abc")
=>
#<MatchData "ab">

A very simple case is /(?~.*)/ . It should be equivalent to empty language ∅ (or /(?~)/) because /.*/ matches to "" and any string contains the empty string, but is not.

# Using Ruby 3.1.2
str = "abcdef"
p /(?~.*)/.match(str)  #=> #<MatchData "abc">