[前][次][番号順一覧][スレッド一覧]

ruby-changes:58592

From: Nobuyoshi <ko1@a...>
Date: Wed, 6 Nov 2019 12:45:57 +0900 (JST)
Subject: [ruby-changes:58592] 82e840ad15 (master): Numbered parameter cannot appear outside block now [Bug #16293]

https://git.ruby-lang.org/ruby.git/commit/?id=82e840ad15

From 82e840ad15bba42b399a21de746967a731240ec2 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 6 Nov 2019 12:41:55 +0900
Subject: Numbered parameter cannot appear outside block now [Bug #16293]


diff --git a/parse.y b/parse.y
index 665ca5f..ac9146a 100644
--- a/parse.y
+++ b/parse.y
@@ -8601,7 +8601,6 @@ parser_numbered_param(struct parser_params *p, int n) https://github.com/ruby/ruby/blob/trunk/parse.y#L8601
     if (n < 0) return false;
 
     if (DVARS_TERMINAL_P(p->lvtbl->args) || DVARS_TERMINAL_P(p->lvtbl->args->prev)) {
-	compile_error(p, "numbered parameter outside block");
 	return false;
     }
     if (p->max_numparam == ORDINAL_PARAM) {
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 5c2a9fc..b55e579 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1457,6 +1457,9 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1457
     assert_syntax_error('-> {-> {_1}; _2}', /numbered parameter is already used/)
     assert_warn(/`_1' is used as numbered parameter/) {eval('proc {_1 = nil}')}
     assert_warn(/`_2' is used as numbered parameter/) {eval('_2=1')}
+    assert_raise_with_message(NameError, /undefined local variable or method `_1'/) {
+      eval('_1')
+    }
     ['class C', 'class << C', 'module M', 'def m', 'def o.m'].each do |c|
       assert_valid_syntax("->{#{c};->{_1};end;_1}\n")
       assert_valid_syntax("->{_1;#{c};->{_1};end}\n")
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]