aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-13 17:14:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-13 17:14:53 +0000
commit2456df7584abf12c62a41f8e82bb2cb4bde202e3 (patch)
tree3becdbc502957b53ba5d05b54d415d9bf7a95cf2
parenta747d4a8e4a88a77d20f572cc766824ba79f6414 (diff)
downloadruby-2456df7584abf12c62a41f8e82bb2cb4bde202e3.tar.gz
parse.y: empty paren
* parse.y (primary): empty parentheses at cmdarg can be null. [ruby-core:68477] [Bug #10957] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--parse.y4
-rw-r--r--test/ruby/test_syntax.rb6
3 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ea4f583b78..2b22b77d10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Mar 14 02:14:50 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (primary): empty parentheses at cmdarg can be null.
+ [ruby-core:68477] [Bug #10957]
+
Fri Mar 13 15:04:36 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_close): don't raise on dobule
diff --git a/parse.y b/parse.y
index 2202020e7c..18116f22af 100644
--- a/parse.y
+++ b/parse.y
@@ -2102,7 +2102,7 @@ arg : lhs '=' arg
value_expr($1);
value_expr($3);
$$ = NEW_DOT2($1, $3);
- if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
+ if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) {
deferred_nodes = list_append(deferred_nodes, $$);
}
@@ -2116,7 +2116,7 @@ arg : lhs '=' arg
value_expr($1);
value_expr($3);
$$ = NEW_DOT3($1, $3);
- if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
+ if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) {
deferred_nodes = list_append(deferred_nodes, $$);
}
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 86c1090c30..ace5c8d46e 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -557,6 +557,12 @@ eom
assert_syntax_error(src, /formal argument/, bug10545)
end
+ def test_null_range_cmdarg
+ bug10957 = '[ruby-core:68477] [Bug #10957]'
+ assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957)
+ assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957)
+ end
+
private
def not_label(x) @result = x; @not_label ||= nil end