Skip to content

Commit

Permalink
[ruby/prism] Assume eval context for ruby_parser and ripper
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed May 3, 2024
1 parent 32b1dea commit 1d51e92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3267,7 +3267,11 @@ def visit_yield_node(node)

# Lazily initialize the parse result.
def result
@result ||= Prism.parse(source)
@result ||=
begin
scopes = RUBY_VERSION >= "3.3.0" ? [] : [[]]
Prism.parse(source, scopes: scopes)
end
end

##########################################################################
Expand Down
4 changes: 2 additions & 2 deletions lib/prism/translation/ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1536,13 +1536,13 @@ def visit_write_value(node)
# Parse the given source and translate it into the seattlerb/ruby_parser
# gem's Sexp format.
def parse(source, filepath = "(string)")
translate(Prism.parse(source, filepath: filepath), filepath)
translate(Prism.parse(source, filepath: filepath, scopes: [[]]), filepath)
end

# Parse the given file and translate it into the seattlerb/ruby_parser
# gem's Sexp format.
def parse_file(filepath)
translate(Prism.parse_file(filepath), filepath)
translate(Prism.parse_file(filepath, scopes: [[]]), filepath)
end

class << self
Expand Down

0 comments on commit 1d51e92

Please sign in to comment.