[ruby/error_highlight] Fix error with prism when method given no arguments
such as: p = Proc.new This now matches the RubyVM::AbstractSyntaxTree behavior, which is not to highlight anything. https://github.com/ruby/error_highlight/commit/d5c592a1ba
This commit is contained in:
parent
414a848cc6
commit
2a0ee408af
@ -700,6 +700,9 @@ module ErrorHighlight
|
|||||||
# foo 42
|
# foo 42
|
||||||
# ^^
|
# ^^
|
||||||
def prism_spot_call_for_args
|
def prism_spot_call_for_args
|
||||||
|
# Disallow highlighting arguments if there are no arguments.
|
||||||
|
return if @node.arguments.nil?
|
||||||
|
|
||||||
# Explicitly turn off foo.() syntax because error_highlight expects this
|
# Explicitly turn off foo.() syntax because error_highlight expects this
|
||||||
# to not work.
|
# to not work.
|
||||||
return nil if @node.name == :call && @node.message_loc.nil?
|
return nil if @node.name == :call && @node.message_loc.nil?
|
||||||
|
@ -197,6 +197,15 @@ undefined method `foo' for #{ NIL_RECV_MESSAGE }
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_CALL_arg_7
|
||||||
|
assert_error_message(ArgumentError, <<~END) do
|
||||||
|
tried to create Proc object without a block (ArgumentError)
|
||||||
|
END
|
||||||
|
|
||||||
|
Proc.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_QCALL_1
|
def test_QCALL_1
|
||||||
assert_error_message(NoMethodError, <<~END) do
|
assert_error_message(NoMethodError, <<~END) do
|
||||||
undefined method `foo' for #{ ONE_RECV_MESSAGE }
|
undefined method `foo' for #{ ONE_RECV_MESSAGE }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user