summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-15 23:12:24 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-15 23:12:24 +0900
commit3a3f48fb8fbdbb810d9b675159529970015316b9 (patch)
tree67803cf6672da6f2380172bddf68fcb1e14cf437
parent751d4ab9c2382d60868446cc69fdac0a9f6cdf4a (diff)
Comment lines can be placed between fluent dot now
-rw-r--r--NEWS6
-rw-r--r--parse.y4
-rw-r--r--test/ruby/test_syntax.rb3
3 files changed, 13 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 3848b6df9d..aa9919d837 100644
--- a/NEWS
+++ b/NEWS
@@ -71,6 +71,12 @@ sufficient information, see the ChangeLog file or Redmine
* The flip-flop syntax deprecation is reverted. [Feature #5400]
+* Comment lines can be placed between fluent dot now.
+
+ foo
+ # .bar
+ .baz # => foo.baz
+
=== Core classes updates (outstanding ones only)
Complex::
diff --git a/parse.y b/parse.y
index 60fcf8cd60..c4fad9311f 100644
--- a/parse.y
+++ b/parse.y
@@ -8737,6 +8737,10 @@ parser_yylex(struct parser_params *p)
case '\13': /* '\v' */
space_seen = 1;
break;
+ case '#':
+ pushback(p, c);
+ if (space_seen) dispatch_scan_event(p, tSP);
+ goto retry;
case '&':
case '.': {
dispatch_delayed_token(p, tIGNORED_NL);
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index a904b0dc3a..ec6fc25ae4 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1033,6 +1033,9 @@ eom
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