Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby scanner can't parse complex method definitions #82

Open
nathany opened this issue Oct 28, 2012 · 1 comment
Open

Ruby scanner can't parse complex method definitions #82

nathany opened this issue Oct 28, 2012 · 1 comment
Milestone

Comments

@nathany
Copy link
Contributor

nathany commented Oct 28, 2012

Ruby scanner has problems to recognize method names in more complex forms of singleton method definition.

I have made a test case.

# simple method definitions

def method param1, param2
  # code
end

def method(args, *rest, &block)
  # code
end

def
method(param1, param2)
  # code
end

def \
method(param1, param2)
  # code
end

def # comment
method(param1, param2)
  # code
end

def [];end
def def;end
def end?;end
def a(*) end
def !; end  # Ruby 1.9

# singleton methods

def Class.method
end

def self.method
end

def object.method
end

def $~.method
end

def nil.method
end
def true.method
end
def false.method
end
def __FILE__.method
end
def __LINE__.method
end
def __ENCODING__.method
end
def __ENCODING__.method
end

def @instance_variable.method
end

def @class_variable.method
end

def (Module::Class).method
end

def (complex.expression).method
end

def (complex.expression + another(complex(expression))).method
end

# crazy

def (class Foo
  def initialize(args)
    def yet_another_method; end
  end
end).method(args, *rest, &block)
end

# wrong
def foo.bar.quux
end

The simple cases are working now. Support for def (expression).method is still missing, but possible now that the state handling has been cleaned up.

I just realized we can even have recursive expression singleton method declarations - so the parenthesis nesting depth really has to be saved in the state, not in a local variable.

I still want to get this obscure thing working, but it's not as important as other features in 1.0. So, I postpone the rest of this ticket to 1.1.

From Redmine: http://odd-eyed-code.org/issues/147

@korny
Copy link
Member

korny commented Mar 10, 2013

Another obscure feature that I really want for the Ruby scanner, but it's not important enough to delay 1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants