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

+ emit "endless method def" as :def node. #716

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/AST_FORMAT.md
Expand Up @@ -829,7 +829,7 @@ Format:
Format:

~~~
(def_e :foo (args) (int 42))
(def :foo (args) (int 42))
"def foo() = 42"
~~~ keyword
~~~ name
Expand All @@ -843,7 +843,7 @@ Format:
Format:

~~~
(defs_e (self) :foo (args) (int 42))
(defs (self) :foo (args) (int 42))
"def self.foo() = 42"
~~~ keyword
~~~ name
Expand Down
4 changes: 0 additions & 4 deletions lib/parser/ast/processor.rb
Expand Up @@ -163,8 +163,6 @@ def on_def(node)
])
end

alias on_def_e on_def

def on_defs(node)
definee_node, name, args_node, body_node = *node

Expand All @@ -174,8 +172,6 @@ def on_defs(node)
])
end

alias on_defs_e on_defs

alias on_undef process_regular_node
alias on_alias process_regular_node

Expand Down
4 changes: 2 additions & 2 deletions lib/parser/builders/default.rb
Expand Up @@ -695,7 +695,7 @@ def def_method(def_t, name_t, args,

def def_endless_method(def_t, name_t, args,
assignment_t, body)
n(:def_e, [ value(name_t).to_sym, args, body ],
n(:def, [ value(name_t).to_sym, args, body ],
endless_definition_map(def_t, nil, name_t, assignment_t, body))
end

Expand All @@ -713,7 +713,7 @@ def def_endless_singleton(def_t, definee, dot_t,
assignment_t, body)
return unless validate_definee(definee)

n(:defs_e, [ definee, value(name_t).to_sym, args, body ],
n(:defs, [ definee, value(name_t).to_sym, args, body ],
endless_definition_map(def_t, dot_t, name_t, assignment_t, body))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/parser/meta.rb
Expand Up @@ -16,7 +16,7 @@ module Meta
op_asgn and_asgn ensure rescue arg_expr
or_asgn back_ref nth_ref
match_with_lvasgn match_current_line
module class sclass def defs def_e defs_e undef alias args
module class sclass def defs undef alias args
cbase arg optarg restarg blockarg block_pass kwarg kwoptarg
kwrestarg kwnilarg send csend super zsuper yield block
and not or if when case while until while_post
Expand Down
14 changes: 7 additions & 7 deletions test/test_parser.rb
Expand Up @@ -9563,7 +9563,7 @@ def test_parser_bug_645

def test_endless_method
assert_parses(
s(:def_e, :foo,
s(:def, :foo,
s(:args),
s(:int, 42)),
%q{def foo() = 42},
Expand All @@ -9574,7 +9574,7 @@ def test_endless_method
SINCE_2_8)

assert_parses(
s(:def_e, :inc,
s(:def, :inc,
s(:args, s(:arg, :x)),
s(:send,
s(:lvar, :x), :+,
Expand All @@ -9587,7 +9587,7 @@ def test_endless_method
SINCE_2_8)

assert_parses(
s(:defs_e, s(:send, nil, :obj), :foo,
s(:defs, s(:send, nil, :obj), :foo,
s(:args),
s(:int, 42)),
%q{def obj.foo() = 42},
Expand All @@ -9599,7 +9599,7 @@ def test_endless_method
SINCE_2_8)

assert_parses(
s(:defs_e, s(:send, nil, :obj), :inc,
s(:defs, s(:send, nil, :obj), :inc,
s(:args, s(:arg, :x)),
s(:send,
s(:lvar, :x), :+,
Expand All @@ -9616,7 +9616,7 @@ def test_endless_method
def test_endless_method_forwarded_args_legacy
Parser::Builders::Default.emit_forward_arg = false
assert_parses(
s(:def_e, :foo,
s(:def, :foo,
s(:forward_args),
s(:send, nil, :bar,
s(:forwarded_args))),
Expand Down Expand Up @@ -9646,7 +9646,7 @@ def test_endless_method_without_brackets

def test_endless_method_with_rescue_mod
assert_parses(
s(:def_e, :m,
s(:def, :m,
s(:args),
s(:rescue,
s(:int, 1),
Expand All @@ -9657,7 +9657,7 @@ def test_endless_method_with_rescue_mod
SINCE_2_8)

assert_parses(
s(:defs_e,
s(:defs,
s(:self), :m,
s(:args),
s(:rescue,
Expand Down