Skip to content
Merged
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
5 changes: 1 addition & 4 deletions lib/prism/node_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,7 @@ def signature
case param
when MultiTargetNode
names << [:req]
when NoKeywordsParameterNode, KeywordRestParameterNode,
NoBlockParameterNode, BlockParameterNode,
ForwardingParameterNode
# Invalid syntax, e.g. "def f(**nil, ...)" moves the NoKeywordsParameterNode to posts
when ErrorRecoveryNode
raise "Invalid syntax"
else
names << [:req, param.name]
Expand Down
4 changes: 3 additions & 1 deletion prism/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,9 @@ nodes:
^ ^
- name: rest
type: node?
kind: pattern expression
kind:
- ImplicitRestNode
- SplatNode
comment: |
Represents the rest element of the array pattern.
Expand Down
6 changes: 3 additions & 3 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -4920,9 +4920,9 @@ rb_str_byterindex(VALUE str, VALUE sub, long pos)
* s.size # => 3 # Three 1-byte characters.
* s.bytesize # => 3 # Three bytes.
* s.byterindex('f') # => 0
s.byterindex('o') # => 2
s.byterindex('oo') # => 1
s.byterindex('ooo') # => nil
* s.byterindex('o') # => 2
* s.byterindex('oo') # => 1
* s.byterindex('ooo') # => nil
*
* When +object+ is a Regexp,
* returns the index of the last found substring matching +object+;
Expand Down
7 changes: 7 additions & 0 deletions test/prism/ruby/parameters_signature_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ def test_forwarding
assert_parameters([[:rest, :*], [:keyrest, :**], [:block, :&]], "...")
end

def test_invalid_syntax
e = assert_raise(RuntimeError) do
Prism.parse_statement("def f(**nil, ...); end").parameters.signature
end
assert_equal("Invalid syntax", e.message)
end

private

def assert_parameters(expected, source, compare: true)
Expand Down
14 changes: 10 additions & 4 deletions tool/lib/leakchecker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@ def check_fd_leak(test_name)
}
unless fd_leaked.empty?
unless @@try_lsof == false
open_list = IO.popen(%W[lsof -w -a -d #{fd_leaked.minmax.uniq.join("-")} -p #$$], &:readlines)
if @@try_lsof |= $?.success?
columns = (header = open_list.shift).split
begin
open_list = IO.popen(%W[lsof -w -a -d #{fd_leaked.minmax.uniq.join("-")} -p #$$], &:readlines)
rescue
@@try_lsof = false
else
@@try_lsof |= $?.success?
end
if header = open_list&.shift
columns = header.split
fd_index, node_index = columns.index('FD'), columns.index('NODE')
open_list.reject! do |of|
of = of.chomp.split(' ', node_index + 2)
Expand All @@ -129,8 +135,8 @@ def check_fd_leak(test_name)
false
end
end
puts(header, open_list) unless open_list.empty?
end
puts(header, open_list) unless open_list.empty?
end
end
inspect.each {|fd, (str, pos)|
Expand Down