summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-01 00:12:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-01 00:12:12 +0000
commit7484d07ca765770619b32a744fde15ae240a3517 (patch)
tree40d9811ea3216d54bda5b73fcf7ce8fda14109d9
parent1a2a4084d94b750646874e5f383b34fcc606dcc9 (diff)
parse.y: invalid symbol
* parse.y (parser_yylex): ':' separated by a comment and a newline is not valid as symbol. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_syntax.rb6
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ba4cd1a..b58aebd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Nov 1 09:12:10 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (parser_yylex): ':' separated by a comment and a newline
+ is not valid as symbol.
+
Sat Oct 31 20:15:48 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* test/openssl/test_pair.rb: skipped tests if openssl doesn't support
diff --git a/parse.y b/parse.y
index 4f3d955..bbfcad7 100644
--- a/parse.y
+++ b/parse.y
@@ -8426,7 +8426,7 @@ parser_yylex(struct parser_params *parser)
lex_state = EXPR_DOT;
return tCOLON2;
}
- if (IS_END() || ISSPACE(c)) {
+ if (IS_END() || ISSPACE(c) || c == '#') {
pushback(c);
warn_balanced(":", "symbol literal");
lex_state = EXPR_BEG;
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index a047454..552cf5c 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -612,6 +612,12 @@ eom
end
end
+ def test_invalid_symbol_space
+ assert_syntax_error(": foo", /unexpected ':'/)
+ assert_syntax_error(": #\n foo", /unexpected ':'/)
+ assert_syntax_error(":#\n foo", /unexpected ':'/)
+ end
+
private
def not_label(x) @result = x; @not_label ||= nil end