Closed thesamet closed 7 years ago
Yes, this is clearly a bug. Thanks for reporting!
Just coming back to this: I don't think there is a clean fix that doesn't touch the API.
I'd recommend using a ListMap
for now, but ultimately allowing for a valueMap
as in the current design is simply a bad idea. We'll have to remove the feature and replace it with one that takes a Seq[(String, T)]
as you already recommended.
If the map contains two strings where one is a prefix of the other and valueMap tries the shorter one first, it will never backtrack and try the longer one. Example:
The expectation is to parse "123" successfully, but this example fails with:
As a side note, since the order we try the pairs in the map matters (even if backtracking worked), it would be nice to have a version that takes Seq[(String, T)]