From: TRANS Date: 2005-09-04T09:43:29+09:00 Subject: Re: [ ruby-Bugs-2371 ] Lexic confusion: method/local variable distinction works strange In 9/3/05, noreply@rubyforge.org wrote: > Initial Comment: > I know that Ruby keeps track of local variables while parsing, to allow simpler syntax. But I found a very surprising behaviour: > > class Foo > def bar sym > p sym > end > end > > foo = Foo.new > > bar = 308 # comment this out to make it work > foo.bar :test # this fails: syntax error > > foo_bar :test # this is syntactically correct > > I think it is easy to see that foo.bar is a method, and certainly in a different scope than the bar local variable. Is it possible to say the parser: x.y is always a method, so expect parameters, as you would if no local variable "bar" existed. It has something to do with the fact that it is a symbol parameter (and w/o parenthesis). Changing the parameter to string also allows it to work. Pretty suprising. T.