mjijackson/citrus — pull request #41 by blambeau (2012-02-22 08:45:53+00:00)
Title: Match#method_missing is unsafe

The added test case shows that Kernel::p is actually called in place of Match#method_missing when 'p' is used as a label or rule name.

As any gem might contribute private methods to Object, using Citrus labels (or even rule names, actually) in semantic productions without doing so with Match#captures is unsafe.

Moreover, the addition of any method/helper to the Match class may potentially break an existing grammar, so it breaks Citrus's public API and should probably increment the MAJOR version number.

I imaging two possible ways of fixing this problem:

1) Dynamically generate methods to the matches (from captures) so that labels and rule names are correctly resolved by ruby itself. The main advantage is that it won't lead to break Citrus. There will be an extra cost at `Match#process_events!` time.
2) Remove `method_missing` completely and clearly document that the safe way to go is to use `self[:rule_name]` in semantic production rules.

Any comment on this? If you agree that this is a problem (?) and make a choice for a particular solution, I can complete the pull request with a fix.