Skip to content

Commit 452f786

Browse files
authored
Merge pull request #48 from luke-gru/fix_prism_call_with_noargs
Fix error with prism when method given no arguments
2 parents 9368229 + d5c592a commit 452f786

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/error_highlight/base.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,9 @@ def prism_spot_call_for_name
700700
# foo 42
701701
# ^^
702702
def prism_spot_call_for_args
703+
# Disallow highlighting arguments if there are no arguments.
704+
return if @node.arguments.nil?
705+
703706
# Explicitly turn off foo.() syntax because error_highlight expects this
704707
# to not work.
705708
return nil if @node.name == :call && @node.message_loc.nil?

test/test_error_highlight.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ def test_CALL_arg_6
197197
end
198198
end
199199

200+
def test_CALL_arg_7
201+
assert_error_message(ArgumentError, <<~END) do
202+
tried to create Proc object without a block (ArgumentError)
203+
END
204+
205+
Proc.new
206+
end
207+
end
208+
200209
def test_QCALL_1
201210
assert_error_message(NoMethodError, <<~END) do
202211
undefined method `foo' for #{ ONE_RECV_MESSAGE }

0 commit comments

Comments
 (0)