Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Need specs for each_with_index + Enumerable method interaction

未关闭
#1,283 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
testing

调研方向

检查现有的 Enumerable 规范以及 issue 中关于 each_with_index 与 to_h、uniq 和 zip 交互的示例输出。在不同实现中重现这些案例,然后确定这些交互应归属于何处,以及规范应要求什么行为。完成的标准是涵盖全部三个案例,并确定预期行为。

由索引模型根据 Issue 内容生成。

描述

There are at least three cases from jruby/jruby#8345 where an interaction between an each_with_index Enumerator and an Enumerable method was or is broken in JRuby:

  • to_h
  • uniq
  • zip

Of these, we've fixed uniq and I have a fix in process for to_h but I'm not sure where to put specs for this kind of interaction.

My first thought was in Enumerable specs, since that's where I had to fix things, but I have not come up with a reproduction that doesn't use an each_with_index enumerator. All cases should be specified, though only a few exhibited this differing behavior between CRuby and JRuby.

Running the same example script against TruffleRuby shows similar issues, so I think getting these cases spec'ed would benefit all impls:

$ diff truffleruby_enum_args.txt ruby_enum_args.txt                  
1c1
< truffleruby 24.2.1, like ruby 3.3.7, Oracle GraalVM Native [arm64-darwin20]
---
> ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [arm64-darwin23]
25c25
< filter_map [[1, 2], 0]
---
> filter_map [1, 2]
65c65
< to_h [[1, 2], 0]
---
> to_h [1, 2]
67c67
< uniq [[1, 2], 0]
---
> uniq [1, 2]
70c70
< zip [[[1, 2], 0]]
---
> zip [[1, 2], 0]

It's also possible CRuby is wrong to have special behavior for these methods.

主要语言
Ruby
星标
622
派生
402
平均合并
14 小时 51 分钟
30 天内合并 PR
6

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/spec 的其他 Issue

查看 ruby/spec 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。