aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--ast.c3
-rw-r--r--compile.c9
-rw-r--r--defs/id.def1
-rw-r--r--ext/objspace/objspace.c1
-rw-r--r--ext/ripper/eventids2.c1
-rw-r--r--insns.def11
-rw-r--r--lib/optparse.rb2
-rw-r--r--node.c9
-rw-r--r--node.h2
-rw-r--r--parse.y28
-rw-r--r--test/ripper/test_parser_events.rb7
-rw-r--r--test/ripper/test_scanner_events.rb2
-rw-r--r--test/ruby/test_ast.rb9
-rw-r--r--test/ruby/test_jit.rb7
-rw-r--r--test/ruby/test_method.rb36
-rw-r--r--test/ruby/test_refinement.rb2
-rw-r--r--test/ruby/test_syntax.rb13
18 files changed, 5 insertions, 141 deletions
diff --git a/NEWS b/NEWS
index 893fb6ee13..14e8fd2b35 100644
--- a/NEWS
+++ b/NEWS
@@ -186,9 +186,6 @@ sufficient information, see the ChangeLog file or Redmine
# Previously parsed as: (a, b = raise) rescue [1, 2]
# Now parsed as: a, b = (raise rescue [1, 2])
-* Method reference operator, <code>.:</code> is introduced as an
- experimental feature. [Feature #12125] [Feature #13581]
-
* +yield+ in singleton class syntax is warned and will be deprecated later [Feature #15575].
* Argument forwarding by <code>(...)</code> is introduced. [Feature #16253]
diff --git a/ast.c b/ast.c
index 236560b094..1133fb8a10 100644
--- a/ast.c
+++ b/ast.c
@@ -432,9 +432,6 @@ node_children(rb_ast_t *ast, NODE *node)
NEW_CHILD(ast, node->nd_args));
case NODE_VCALL:
return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
- case NODE_METHREF:
- return rb_ary_new_from_args(2, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid));
case NODE_SUPER:
return rb_ary_new_from_node_args(ast, 1, node->nd_args);
case NODE_ZSUPER:
diff --git a/compile.c b/compile.c
index 8c83903115..b45aaef6ee 100644
--- a/compile.c
+++ b/compile.c
@@ -4742,11 +4742,9 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
case NODE_OPCALL:
case NODE_VCALL:
case NODE_FCALL:
- case NODE_METHREF:
case NODE_ATTRASGN:{
const int explicit_receiver =
(type == NODE_CALL || type == NODE_OPCALL ||
- type == NODE_METHREF ||
(type == NODE_ATTRASGN && !private_recv_p(node)));
if (!lfinish[1] && (node->nd_args || explicit_receiver)) {
@@ -8484,13 +8482,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
break;
}
- case NODE_METHREF:
- CHECK(COMPILE(ret, "receiver", node->nd_recv));
- ADD_ELEM(ret, &new_insn_body(iseq, line, BIN(methodref), 1, ID2SYM(node->nd_mid))->link);
- if (popped) {
- ADD_INSN(ret, line, pop);
- }
- break;
default:
UNKNOWN_NODE("iseq_compile_each", node, COMPILE_NG);
ng:
diff --git a/defs/id.def b/defs/id.def
index a35b5d55f9..fc7a04ffbc 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -130,7 +130,6 @@ token_ops = %[\
ANDOP &&
OROP ||
ANDDOT &.
- METHREF .:
]
class KeywordError < RuntimeError
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index 927c5b543c..311e687206 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -474,7 +474,6 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_DSYM);
COUNT_NODE(NODE_ATTRASGN);
COUNT_NODE(NODE_LAMBDA);
- COUNT_NODE(NODE_METHREF);
COUNT_NODE(NODE_ARYPTN);
COUNT_NODE(NODE_HSHPTN);
#undef COUNT_NODE
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c
index 4ab8c4c292..cdac2081e6 100644
--- a/ext/ripper/eventids2.c
+++ b/ext/ripper/eventids2.c
@@ -261,7 +261,6 @@ ripper_token2eventid(enum yytokentype tok)
[tSTAR] = O(op),
[tDSTAR] = O(op),
[tANDDOT] = O(op),
- [tMETHREF] = O(op),
[tSTRING_BEG] = O(tstring_beg),
[tSTRING_CONTENT] = O(tstring_content),
[tSTRING_DBEG] = O(embexpr_beg),
diff --git a/insns.def b/insns.def
index 1333c09869..df505808ce 100644
--- a/insns.def
+++ b/insns.def
@@ -719,17 +719,6 @@ checktype
ret = (TYPE(val) == (int)type) ? Qtrue : Qfalse;
}
-/* get frozen method reference. */
-DEFINE_INSN
-methodref
-(ID id)
-(VALUE val)
-(VALUE ret)
-{
- ret = rb_obj_method(val, ID2SYM(id));
- RB_OBJ_FREEZE_RAW(ret);
-}
-
/**********************************************************/
/* deal with control flow 1: class/module */
/**********************************************************/
diff --git a/lib/optparse.rb b/lib/optparse.rb
index b6d7170487..614ebc3eae 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1781,7 +1781,7 @@ XXX
visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
}
exc = ambiguous ? AmbiguousOption : InvalidOption
- raise exc.new(opt, additional: self.:additional_message.curry[typ])
+ raise exc.new(opt, additional: self.method(:additional_message).curry[typ])
end
private :complete
diff --git a/node.c b/node.c
index 6477446c7b..3514060ecb 100644
--- a/node.c
+++ b/node.c
@@ -954,15 +954,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_NODE(nd_args, "arguments");
return;
- case NODE_METHREF:
- ANN("method reference");
- ANN("format: [nd_recv].:[nd_mid]");
- ANN("example: foo.:method");
- F_NODE(nd_recv, "receiver");
- LAST_NODE;
- F_ID(nd_mid, "method name");
- return;
-
case NODE_LAMBDA:
ANN("lambda expression");
ANN("format: -> [nd_body]");
diff --git a/node.h b/node.h
index 8f43f45422..79fa29d56b 100644
--- a/node.h
+++ b/node.h
@@ -122,7 +122,6 @@ enum node_type {
NODE_DSYM,
NODE_ATTRASGN,
NODE_LAMBDA,
- NODE_METHREF,
NODE_ARYPTN,
NODE_HSHPTN,
NODE_LAST
@@ -378,7 +377,6 @@ typedef struct RNode {
#define NEW_PREEXE(b,loc) NEW_SCOPE(b,loc)
#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
-#define NEW_METHREF(r,m,loc) NEW_NODE(NODE_METHREF,r,m,0,loc)
#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
#define NODE_REQUIRED_KEYWORD_P(node) ((node)->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD)
diff --git a/parse.y b/parse.y
index 6d0564476d..57b97a92e3 100644
--- a/parse.y
+++ b/parse.y
@@ -1114,7 +1114,6 @@ static int looking_at_eol_p(struct parser_params *p);
%token tRSHFT RUBY_TOKEN(RSHFT) ">>"
%token <id> tANDDOT RUBY_TOKEN(ANDDOT) "&."
%token <id> tCOLON2 RUBY_TOKEN(COLON2) "::"
-%token <id> tMETHREF RUBY_TOKEN(METHREF) ".:"
%token tCOLON3 ":: at EXPR_BEG"
%token <id> tOP_ASGN "operator-assignment" /* +=, -= etc. */
%token tASSOC "=>"
@@ -3064,13 +3063,6 @@ primary : literal
/*% %*/
/*% ripper: retry! %*/
}
- | primary_value tMETHREF operation2
- {
- /*%%%*/
- $$ = NEW_METHREF($1, $3, &@$);
- /*% %*/
- /*% ripper: methref!($1, $3) %*/
- }
;
primary_value : primary
@@ -9232,8 +9224,7 @@ parser_yylex(struct parser_params *p)
case '.': {
int is_beg = IS_BEG();
SET_LEX_STATE(EXPR_BEG);
- switch (c = nextc(p)) {
- case '.':
+ if ((c = nextc(p)) == '.') {
if ((c = nextc(p)) == '.') {
if (p->lex.paren_nest == 0 && looking_at_eol_p(p)) {
rb_warn0("... at EOL, should be parenthesized?");
@@ -9242,23 +9233,6 @@ parser_yylex(struct parser_params *p)
}
pushback(p, c);
return is_beg ? tBDOT2 : tDOT2;
- case ':':
- switch (c = nextc(p)) {
- default:
- if (!parser_is_identchar(p)) break;
- /* fallthru */
- case '!': case '%': case '&': case '*': case '+':
- case '-': case '/': case '<': case '=': case '>':
- case '[': case '^': case '`': case '|': case '~':
- pushback(p, c);
- SET_LEX_STATE(EXPR_DOT);
- return tMETHREF;
- case -1:
- break;
- }
- pushback(p, c);
- c = ':';
- break;
}
pushback(p, c);
if (c != -1 && ISDIGIT(c)) {
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 1be2833a4b..feb3db05d8 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -443,13 +443,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal "[call(ref(self),&.,foo,[])]", tree
end
- def test_methref
- thru_methref = false
- tree = parse("obj.:foo", :on_methref) {thru_methref = true}
- assert_equal true, thru_methref
- assert_equal "[methref(vcall(obj),foo)]", tree
- end
-
def test_excessed_comma
thru_excessed_comma = false
parse("proc{|x,|}", :on_excessed_comma) {thru_excessed_comma = true}
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index 641310b384..d2f8479a33 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -562,8 +562,6 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('op', ':[]=')
assert_equal ['&.'],
scan('op', 'a&.f')
- assert_equal %w(.:),
- scan('op', 'obj.:foo')
assert_equal [],
scan('op', %q[`make all`])
end
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index a4c18d0ad6..4c156650b8 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -264,15 +264,6 @@ class TestAst < Test::Unit::TestCase
assert_equal(:SCOPE, defn.type)
end
- def test_methref
- node = RubyVM::AbstractSyntaxTree.parse("obj.:foo")
- _, _, body = *node.children
- assert_equal(:METHREF, body.type)
- recv, mid = body.children
- assert_equal(:VCALL, recv.type)
- assert_equal(:foo, mid)
- end
-
def test_dstr
node = parse('"foo#{1}bar"')
_, _, body = *node.children
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
index 803a8e4996..3ef60df7a1 100644
--- a/test/ruby/test_jit.rb
+++ b/test/ruby/test_jit.rb
@@ -482,13 +482,6 @@ class TestJIT < Test::Unit::TestCase
end;
end
- def test_compile_insn_methodref
- assert_compile_once("#{<<~"begin;"}\n#{<<~'end;'}", result_inspect: '"main"', insns: %i[methodref])
- begin;
- self.:inspect.call
- end;
- end
-
def test_compile_insn_inlinecache
assert_compile_once('Struct', result_inspect: 'Struct', insns: %i[opt_getinlinecache opt_setinlinecache])
end
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 1a1ac59334..afab7eb900 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -1125,42 +1125,6 @@ class TestMethod < Test::Unit::TestCase
}
end
- def test_method_reference_operator
- m = 1.:succ
- assert_predicate(m, :frozen?)
- assert_equal(1.method(:succ), m)
- assert_equal(2, m.())
- m = 1.:+
- assert_predicate(m, :frozen?)
- assert_equal(1.method(:+), m)
- assert_equal(42, m.(41))
- m = 1.:-@
- assert_predicate(m, :frozen?)
- assert_equal(1.method(:-@), m)
- assert_equal(-1, m.())
- o = Object.new
- def o.foo; 42; end
- assert_predicate(o.:foo, :frozen?)
- m = o.method(:foo)
- assert_equal(m, o.:foo)
- def o.method(m); nil; end
- assert_equal(m, o.:foo)
- assert_nil(o.method(:foo))
- end
-
- def test_method_reference_freeze_state
- m = 1.:succ
- assert_predicate(m, :frozen?, "dot-symbol method reference should be frozen")
- m = 1.method(:succ)
- assert_not_predicate(m, :frozen?, "#method method reference should not be frozen")
- o = Object.new
- def o.foo; 42; end
- m = o.:foo
- assert_predicate(m, :frozen?, "dot-symbol method reference should be frozen")
- m = o.method(:foo)
- assert_not_predicate(m, :frozen?, "#method method reference should not be frozen")
- end
-
def test_umethod_bind_call
foo = Base.instance_method(:foo)
assert_equal(:base, foo.bind_call(Base.new))
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 4be0720983..34451de482 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -235,7 +235,7 @@ class TestRefinement < Test::Unit::TestCase
meth.call(3)
EOS
assert_equal(:refine_pow, eval_using(MethodIntegerPowEx, "2.pow(3)"))
- assert_equal(:refine_pow, eval_using(MethodIntegerPowEx, "2.:pow.(3)"))
+ assert_equal(:refine_pow, eval_using(MethodIntegerPowEx, "2.method(:pow).(3)"))
end
module InstanceMethodIntegerPowEx
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 622017be83..286beb7074 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -93,13 +93,6 @@ class TestSyntax < Test::Unit::TestCase
assert_valid_syntax("tap (proc do end)", __FILE__, bug9726)
end
- def test_methodref_literal
- assert_separately [], <<-EOS
- eval 'nil.:|;1'
- 1000.times{eval 'nil.:|;1'}
- EOS
- end
-
def test_array_kwsplat_hash
kw = {}
h = {a: 1}
@@ -1014,10 +1007,8 @@ eom
def test_fluent_dot
assert_valid_syntax("a\n.foo")
assert_valid_syntax("a\n&.foo")
- assert_valid_syntax("a\n.:foo")
assert_valid_syntax("a #\n#\n.foo\n")
assert_valid_syntax("a #\n#\n&.foo\n")
- assert_valid_syntax("a #\n#\n.:foo\n")
end
def test_safe_call_in_massign_lhs
@@ -1534,8 +1525,8 @@ eom
assert_warning(/\A\z|:(?!#{__LINE__+1})\d+: #{warning}/o) {
assert_equal([[], {}], obj.foo({}))
}
- assert_equal(-1, obj.:foo.arity)
- parameters = obj.:foo.parameters
+ assert_equal(-1, obj.method(:foo).arity)
+ parameters = obj.method(:foo).parameters
assert_equal(:rest, parameters.dig(0, 0))
assert_equal(:block, parameters.dig(1, 0))
end