ruby-changes:54521
From: nobu <ko1@a...>
Date: Sun, 6 Jan 2019 14:07:14 +0900 (JST)
Subject: [ruby-changes:54521] nobu:r66736 (trunk): ast.c: argument must be a string
nobu 2019-01-06 14:07:10 +0900 (Sun, 06 Jan 2019) New Revision: 66736 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66736 Log: ast.c: argument must be a string [ruby-core:90904] [Bug #15511] Modified files: trunk/ast.c trunk/test/ruby/test_ast.rb Index: ast.c =================================================================== --- ast.c (revision 66735) +++ ast.c (revision 66736) @@ -96,7 +96,7 @@ rb_ast_parse_str(VALUE str) https://github.com/ruby/ruby/blob/trunk/ast.c#L96 { rb_ast_t *ast = 0; - str = rb_check_string_type(str); + StringValue(str); ast = rb_parser_compile_string_path(ast_parse_new(), Qnil, str, 1); return ast_parse_done(ast); } Index: test/ruby/test_ast.rb =================================================================== --- test/ruby/test_ast.rb (revision 66735) +++ test/ruby/test_ast.rb (revision 66736) @@ -134,6 +134,14 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L134 assert_raise(TypeError) {RubyVM::AbstractSyntaxTree::Node.allocate} end + def test_parse_argument_error + assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(0)} + assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(nil)} + assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(false)} + assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(true)} + assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(:foo)} + end + def test_column_with_long_heredoc_identifier term = "A"*257 ast = RubyVM::AbstractSyntaxTree.parse("<<-#{term}\n""ddddddd\n#{term}\n") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/