Skip to content

Commit

Permalink
[ruby/prism] Fix majority of RBS type mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
nixme authored and matzbot committed Dec 15, 2023
1 parent 2e8cfca commit b954224
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions prism/templates/lib/prism/node.rb.erb
Expand Up @@ -44,19 +44,19 @@ module Prism
<%- end -%>
class <%= node.name -%> < Node
<%- node.fields.each do |field| -%>
# attr_reader <%= field.name %>: <%= field.rbs_class %>
# <%= "private " if field.is_a?(Prism::FlagsField) %>attr_reader <%= field.name %>: <%= field.rbs_class %>
<%= "private " if field.is_a?(Prism::FlagsField) %>attr_reader :<%= field.name %>
<%- end -%>
# def initialize: (<%= (node.fields.map { |field| "#{field.name}: #{field.rbs_class}" } + ["location: Location"]).join(", ") %>) -> void
# def initialize: (<%= (node.fields.map { |field| "#{field.rbs_class} #{field.name}" } + ["Location location"]).join(", ") %>) -> void
def initialize(<%= (node.fields.map(&:name) + ["location"]).join(", ") %>)
<%- node.fields.each do |field| -%>
@<%= field.name %> = <%= field.name %>
<%- end -%>
@location = location
end

# def accept: (visitor: Visitor) -> void
# def accept: (Visitor visitor) -> void
def accept(visitor)
visitor.visit_<%= node.human %>(self)
end
Expand Down Expand Up @@ -137,7 +137,7 @@ module Prism
# def deconstruct: () -> Array[nil | Node]
alias deconstruct child_nodes

# def deconstruct_keys: (keys: Array[Symbol]) -> Hash[Symbol, nil | Node | Array[Node] | String | Token | Array[Token] | Location]
# def deconstruct_keys: (Array[Symbol] keys) -> { <%= (node.fields.map { |field| "#{field.name}: #{field.rbs_class}" } + ["location: Location"]).join(", ") %> }
def deconstruct_keys(keys)
{ <%= (node.fields.map { |field| "#{field.name}: #{field.name}" } + ["location: location"]).join(", ") %> }
end
Expand Down Expand Up @@ -170,7 +170,7 @@ module Prism
<%- end -%>
<%- end -%>

# def inspect(inspector: NodeInspector) -> String
# def inspect(NodeInspector inspector) -> String
def inspect(inspector = NodeInspector.new)
inspector << inspector.header(self)
<%- node.fields.each_with_index do |field, index| -%>
Expand Down

0 comments on commit b954224

Please sign in to comment.