comby-tools/comby

A match expression followed by a rewrite expression using a named whitespace matcher produces unexpected output

markrian opened this issue · 0 comments

Describe the bug

Running this configuration:

[foo]
match=":[1]"
rewrite=":[1]"
rule="""
where
match :[1] { ":[_~foo]" -> true },
rewrite :[1] { ":[ _]" -> "|" },
"""

Against the string one foo two three produces one | two three, whereas I would expect it to produce one|foo|two|three.

Interestingly changing the order of the match and rewrite fixes it. That is, changing the rule above to the following produces the expected output:

where
rewrite :[1] { ":[ _]" -> "|" },
match :[1] { ":[_~foo]" -> true },

Also interestingly, using the original order but using a plain space character instead of the named whitespace matcher also produces the expected out:

where
match :[1] { ":[_~foo]" -> true },
rewrite :[1] { " " -> "|" },

Reproducing

  • If this looks like a bug in the matcher, go to https://comby.live and paste a shared link below:

https://bit.ly/43kUxrz