From d723307e88f030d9289fe8eadaca693f81fd9578 Mon Sep 17 00:00:00 2001 From: tompng Date: Sun, 29 Oct 2023 02:58:05 +0900 Subject: [PATCH] specify prism >=0.15.1 in gemspec --- katakata_irb.gemspec | 2 +- lib/katakata_irb/type_analyzer.rb | 5 ++--- test/test_katakata_irb.rb | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/katakata_irb.gemspec b/katakata_irb.gemspec index 822c0ee..1198c84 100644 --- a/katakata_irb.gemspec +++ b/katakata_irb.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| # Uncomment to register a new dependency of your gem spec.add_dependency 'irb', '>= 1.4.0' spec.add_dependency 'reline', '>= 0.3.0' - spec.add_dependency 'prism', '>= 0.14.0' + spec.add_dependency 'prism', '>= 0.15.1' spec.add_dependency 'rbs' # For more information and examples about making a new gem, check out our diff --git a/lib/katakata_irb/type_analyzer.rb b/lib/katakata_irb/type_analyzer.rb index 013f1f5..16635e4 100644 --- a/lib/katakata_irb/type_analyzer.rb +++ b/lib/katakata_irb/type_analyzer.rb @@ -319,8 +319,7 @@ def evaluate_index_and_write_node(node, scope) = evaluate_call_write(node, scope def evaluate_index_or_write_node(node, scope) = evaluate_call_write(node, scope, :or, :[]=) def evaluate_call_write(node, scope, operator, write_name) receiver_type = evaluate node.receiver, scope - if node.respond_to? :arguments - # Prism >= 0.15.0, Call{Operator,And,Or}WriteNode does not have arguments + if write_name == :[]= args_types, kwargs_types, block_sym_node, has_block = evaluate_call_node_arguments node, scope else args_types = [] @@ -795,7 +794,7 @@ def evaluate_missing_node(_node, _scope) = KatakataIrb::Types::NIL def evaluate_call_node_arguments(call_node, scope) # call_node.arguments is Prism::ArgumentsNode arguments = call_node.arguments&.arguments&.dup || [] - block_arg = call_node.block.expression if call_node.respond_to?(:block) && call_node.block.is_a?(Prism::BlockArgumentNode) + block_arg = call_node.block.expression if call_node.block.is_a?(Prism::BlockArgumentNode) kwargs = arguments.pop.elements if arguments.last.is_a?(Prism::KeywordHashNode) args_types = arguments.map do |arg| case arg diff --git a/test/test_katakata_irb.rb b/test/test_katakata_irb.rb index f2da7cc..52f889d 100644 --- a/test/test_katakata_irb.rb +++ b/test/test_katakata_irb.rb @@ -60,8 +60,6 @@ def test_prism_node_names ignore_class_names = [ # Not traversed 'Prism::BlockLocalVariableNode', - # Added in prism 0.15.0 - 'Prism::IndexAndWriteNode', 'Prism::IndexOperatorWriteNode', 'Prism::IndexOrWriteNode', # Removed in prism > 0.15.1 'Prism::RequiredDestructuredParameterNode' ]