[ruby/prism] Fix up steep issues

https://github.com/ruby/prism/commit/21d314eb2e
This commit is contained in:
Kevin Newton 2024-06-03 13:31:57 -04:00 коммит произвёл git
Родитель 520ab22725
Коммит 77581dd45b
2 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -5,10 +5,13 @@
module Prism
class Node
def deprecated(*replacements) # :nodoc:
location = caller_locations(1, 1)
location = location[0].label if location
suggest = replacements.map { |replacement| "#{self.class}##{replacement}" }
warn(<<~MSG, category: :deprecated)
[deprecation]: #{self.class}##{caller_locations(1, 1)[0].label} is deprecated \
and will be removed in the next major version. Use #{suggest.join("/")} instead.
[deprecation]: #{self.class}##{location} is deprecated and will be \
removed in the next major version. Use #{suggest.join("/")} instead.
#{(caller(1, 3) || []).join("\n")}
MSG
end
@ -261,9 +264,10 @@ module Prism
end
posts.each do |param|
if param.is_a?(MultiTargetNode)
case param
when MultiTargetNode
names << [:req]
elsif param.is_a?(NoKeywordsParameterNode)
when NoKeywordsParameterNode, KeywordRestParameterNode, ForwardingParameterNode
# Invalid syntax, e.g. "def f(**nil, ...)" moves the NoKeywordsParameterNode to posts
raise "Invalid syntax"
else

Просмотреть файл

@ -25,6 +25,7 @@ module Prism
class Newlines < Visitor
# Create a new Newlines visitor with the given newline offsets.
def initialize(lines)
# @type var lines: Integer
@lines = Array.new(1 + lines, false)
end