Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Source.parse crashes with selector-less sendish node #1433

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/steep/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def self.sendish_node?(node)
receiver_node, name, _, location = deconstruct_send_node!(send_node)

if receiver_node
if location.dot
if location.dot && location.selector
location.selector.line
end
else
Expand Down
15 changes: 15 additions & 0 deletions test/source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,21 @@ def test: [T] () { (T) -> void } -> T
end
end

def test_selectorless_sendish_node_with_annotation_comment
with_factory({ Pathname("foo.rbs") => <<-RBS }) do |factory|
RBS
source = Steep::Source.parse(<<-EOF, path: Pathname("foo.rb"), factory: factory)
proc{}.() do
x #: nil
end
EOF

source.node.children[0].tap do |node|
assert_equal :send, node.type
end
end
end

def test_find_comment
with_factory() do |factory|
source = Steep::Source.parse(<<~RUBY, path: Pathname("foo.rb"), factory: factory)
Expand Down
Loading