1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Do not set $! to SyntaxError when error tolerant

This commit is contained in:
Nobuyoshi Nakada 2022-10-09 17:43:16 +09:00
parent d9e2ef6000
commit 546566d34b
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
Notes: git 2022-10-09 20:23:29 +09:00
2 changed files with 3 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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)