Skip to content

Remove false results from filter_map - #375

Merged
grosser merged 2 commits into
grosser:masterfrom
OskarEichler:codex/filter-map-truthy-results
Aug 28, 2026
Merged

Remove false results from filter_map#375
grosser merged 2 commits into
grosser:masterfrom
OskarEichler:codex/filter-map-truthy-results

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary

Match Enumerable#filter_map by keeping only truthy block results.

Reproduction and verification

Parallel.filter_map([nil, false, true, 0, ""], in_threads: 0) { |x| x } currently keeps false. Expected [true, 0, ""]. The same discrepancy occurs with threads/processes; the candidate also matches Enumerable for Ractor callbacks.

Six direct/thread/process cases fail before and pass after; a mixed-value model also covers Ractors. Existing filter_map example passes.

The combined installed-release candidate passes 800 model checks across direct, thread, process and Ractor modes. Existing selected suite: 165 examples, zero failures, nine pending, baseline and candidate on rbenv Ruby 4.0.6. Global process-name kill tests and the 200-process stress example were excluded for shared-host safety. SQLite examples use temporary databases. An external verification bundle uses already-installed dependencies; upstream Gemfile/lockfile/tests remain unchanged.

Runtime RuboCop passes. Full upstream RuboCop reports the same pre-existing RSpec/MatchWithSimpleRegex offense in spec/parallel_spec.rb:278 on both versions; no full green-lint claim. Gem packaging retains 2.1.0, Ruby >= 3.3, all four published paths and metadata, with no dependency changes.

Compatibility and limitations

Intentional correction: false values are removed. Truthy zero, empty String, empty Array and empty Hash remain. No flattening or block invocation changes.

No tests were added or modified under the consuming repository's no-new-tests policy. Reproductions/model checks are external scratch scripts. No production operations or claim of complete concurrency/platform coverage.

@grosser grosser left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yikes, what a bug :D

@grosser
grosser merged commit 518730b into grosser:master Aug 28, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants