mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
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]
This commit is contained in:
parent
7775d14356
commit
fbbdbdd891
Notes:
git
2022-10-08 17:59:35 +09:00
5 changed files with 50 additions and 20 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue