Matching a pattern that is a grammar with no captures throws an error
Description: This case may be rare in practice, but there's an example in the RPL patterns that are part of the Rosie distribution:
json.json_discard. The bug occurs only when the match succeeds.
Versions: This bug is present in v0.99i and appears to go all the way back to v0.99a. It was likely the result of a significant change to the compiler that occurred just prior to that.
Work around: Capture something! (E.g. the
json pattern works, and it is defined as a capturing version of the alias
The bug looks like this:
jjennings$ rosie json.json_discard /tmp/test.json /Users/jjennings/Work/Dev/public/rosie-pattern-language/bin/lua: src/core/common.lua:233: bad argument #1 to 'next' (table expected, got number) stack traceback: [C]: in function 'next' src/core/common.lua:233: in function 'common.decode_match' src/core/color-output.lua:164: in function 'color_string_from_leaf_nodes' src/core/engine.lua:177: in function <src/core/engine.lua:146> (...tail calls...) ...nings/Work/Dev/public/rosie-pattern-language/src/run.lua:303: in function 'process_pattern_against_file' ...nings/Work/Dev/public/rosie-pattern-language/src/run.lua:354: in function 'run' ...nings/Work/Dev/public/rosie-pattern-language/src/run.lua:371: in main chunk [C]: in ?