summaryrefslogtreecommitdiff
diff options
authorNobuyoshi Nakada <[email protected]>2022-10-09 17:43:16 +0900
committerNobuyoshi Nakada <[email protected]>2022-10-09 19:07:21 +0900
commit546566d34b37fb5a028bcbe6bafa8248877f06ca (patch)
tree6f09b7db0e1daeb46f2fd10d82926610199f5f97
parentd9e2ef6000a7a7621e110a7092f09e273eb81fcb (diff)
Do not set `$!` to `SyntaxError` when error tolerant
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6517
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_ast.rb2
2 files changed, 3 insertions, 1 deletions
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)
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
end
end
STR
+ assert_nil($!)
assert_equal(:SCOPE, node.type)
end
@@ -965,6 +966,7 @@ dummy
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)