Skip to content

Commit

Permalink
parse.y: invalid symbol
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu committed Nov 1, 2015
1 parent 1a2a408 commit 7484d07
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions 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
Expand Down
2 changes: 1 addition & 1 deletion parse.y
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions test/ruby/test_syntax.rb
Expand Up @@ -612,6 +612,12 @@ def test_too_big_nth_ref
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
Expand Down

0 comments on commit 7484d07

Please sign in to comment.