Skip to content

ruby: repeated_field aliases each_index to each_with_index - thus incorrectly returning the each not the index #7806

@jufemaiz

Description

@jufemaiz

Aliased method for each_index is invalid:

# array aliases into enumerable
alias_method :each_index, :each_with_index
alias_method :slice, :[]
alias_method :values_at, :select
alias_method :map, :collect

Ref:

What version of protobuf and what language are you using?
Version: master
Language: ruby

What operating system (Linux, Windows, ...) and version?

Docker: ruby:2.7-slim-buster

What runtime / compiler are you using (e.g., python version or gcc version)

N/A

What did you do?
Steps to reproduce the behavior:

  1. have a proto with a repeated_field
  2. build a ruby library
  3. make use of each_index

What did you expect to see

The index of the repeated field.

What did you see instead?

The repeated field's value instead.

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions