ruby-changes:73941
From: Nobuyoshi <ko1@a...>
Date: Sun, 9 Oct 2022 20:23:27 +0900 (JST)
Subject: [ruby-changes:73941] 546566d34b (master): Do not set `$!` to `SyntaxError` when error tolerant
https://git.ruby-lang.org/ruby.git/commit/?id=546566d34b From 546566d34b37fb5a028bcbe6bafa8248877f06ca Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 9 Oct 2022 17:43:16 +0900 Subject: Do not set `$!` to `SyntaxError` when error tolerant --- parse.y | 2 +- test/ruby/test_ast.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 3f0eb54d4e..f4b4b8f3d1 100644 --- a/parse.y +++ b/parse.y @@ -6488,8 +6488,8 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L6488 if (!mesg) { mesg = rb_class_new_instance(0, 0, rb_eSyntaxError); } - rb_set_errinfo(mesg); if (!p->error_tolerant) { + rb_set_errinfo(mesg); return FALSE; } } diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index faa989c2fb..b91880be6d 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -576,6 +576,7 @@ dummy https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L576 end end STR + assert_nil($!) assert_equal(:SCOPE, node.type) end @@ -965,6 +966,7 @@ dummy https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L966 def assert_error_tolerant(src, expected) node = RubyVM::AbstractSyntaxTree.parse(src, error_tolerant: true) + assert_nil($!) str = "" PP.pp(node, str, 80) assert_equal(expected, str) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/