From fbbdbdd8911ffb24d98bb71c7c33d24609ce7dfe Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 25 Sep 2022 17:53:44 +0900 Subject: Add error_tolerant option to RubyVM::AST If this option is enabled, SyntaxError is not raised and Node is returned even if passed script is broken. [Feature #19013] --- test/ruby/test_ast.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index d28d7e1fab..c2c5356f83 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -565,4 +565,17 @@ dummy assert_in_out_err(["-e", "def foo; end; pp RubyVM::AbstractSyntaxTree.of(method(:foo)).type"], "", [":SCOPE"], []) end + + def test_error_tolerant + node = RubyVM::AbstractSyntaxTree.parse(<<~STR, error_tolerant: true) + class A + def m + if; + a = 10 + end + end + STR + + assert_equal(:SCOPE, node.type) + end end -- cgit v1.2.3