* [ruby-core:120472] [Ruby master Bug#21001] unexpected nil result from proc with ensure and next
@ 2025-01-03 20:10 aharpervc (Andrew Harper) via ruby-core
2025-01-05 0:14 ` [ruby-core:120480] " ydah (Yudai Takada) via ruby-core
2025-01-06 0:57 ` [ruby-core:120491] " kddnewton (Kevin Newton) via ruby-core
0 siblings, 2 replies; 3+ messages in thread
From: aharpervc (Andrew Harper) via ruby-core @ 2025-01-03 20:10 UTC (permalink / raw)
To: ruby-core; +Cc: aharpervc (Andrew Harper)
Issue #21001 has been reported by aharpervc (Andrew Harper).
----------------------------------------
Bug #21001: unexpected nil result from proc with ensure and next
https://bugs.ruby-lang.org/issues/21001
* Author: aharpervc (Andrew Harper)
* Status: Open
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Hello,
I have noticed a different program behavior in Ruby 3.4 compared to previous versions. This is a simplified example for debugging that returns the expected result in Ruby 3.3 but nil in Ruby 3.4
Here is the example program:
``` ruby
puts "Ruby: #{RUBY_VERSION}"
# okay all versions
# RUN_ARRAY = [1]
# fails ruby 3.4 only
RUN_ARRAY = [1,2]
MAP_PROC = Proc.new do |&blk|
block_results = []
RUN_ARRAY.each do |value|
block_value = blk.call(value)
block_results.push block_value
end
block_results
ensure
next block_results
end
test_fn_results = MAP_PROC.call do |value|
break if value > 1
next value
end
puts test_fn_results.inspect
```
For Ruby 3.3.6 the output is:
```
Ruby: 3.3.6
[1]
```
For Ruby 3.4.1 the output is:
```
Ruby: 3.4.1
nil
```
I am expecting the Ruby 3.3 output even for Ruby 3.4. This appears to be a bug, since the program implementation is unchanged. Perhaps there is a bug in the code that is now only showing up with Ruby 3.4, but that seemed unlikely since it's working as expected in other versions.
Thank you
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:120480] [Ruby master Bug#21001] unexpected nil result from proc with ensure and next
2025-01-03 20:10 [ruby-core:120472] [Ruby master Bug#21001] unexpected nil result from proc with ensure and next aharpervc (Andrew Harper) via ruby-core
@ 2025-01-05 0:14 ` ydah (Yudai Takada) via ruby-core
2025-01-06 0:57 ` [ruby-core:120491] " kddnewton (Kevin Newton) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: ydah (Yudai Takada) via ruby-core @ 2025-01-05 0:14 UTC (permalink / raw)
To: ruby-core; +Cc: ydah (Yudai Takada)
Issue #21001 has been updated by ydah (Yudai Takada).
Note) This does not occur even in Ruby 3.4.1 when `--parser=parse.y`.
```
❯ ruby --parser=parse.y -e 'puts "Ruby: #{RUBY_VERSION}"
# okay all versions
# RUN_ARRAY = [1]
# fails ruby 3.4 only
RUN_ARRAY = [1,2]
MAP_PROC = Proc.new do |&blk|
block_results = []
RUN_ARRAY.each do |value|
block_value = blk.call(value)
block_results.push block_value
end
block_results
ensure
next block_results
end
test_fn_results = MAP_PROC.call do |value|
break if value > 1
next value
end
puts test_fn_results.inspect'
Ruby: 3.4.1
[1]
```
----------------------------------------
Bug #21001: unexpected nil result from proc with ensure and next
https://bugs.ruby-lang.org/issues/21001#change-111264
* Author: aharpervc (Andrew Harper)
* Status: Open
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Hello,
I have noticed a different program behavior in Ruby 3.4 compared to previous versions. This is a simplified example for debugging that returns the expected result in Ruby 3.3 but nil in Ruby 3.4
Here is the example program:
``` ruby
puts "Ruby: #{RUBY_VERSION}"
# okay all versions
# RUN_ARRAY = [1]
# fails ruby 3.4 only
RUN_ARRAY = [1,2]
MAP_PROC = Proc.new do |&blk|
block_results = []
RUN_ARRAY.each do |value|
block_value = blk.call(value)
block_results.push block_value
end
block_results
ensure
next block_results
end
test_fn_results = MAP_PROC.call do |value|
break if value > 1
next value
end
puts test_fn_results.inspect
```
For Ruby 3.3.6 the output is:
```
Ruby: 3.3.6
[1]
```
For Ruby 3.4.1 the output is:
```
Ruby: 3.4.1
nil
```
I am expecting the Ruby 3.3 output even for Ruby 3.4. This appears to be a bug, since the program implementation is unchanged. Perhaps there is a bug in the code that is now only showing up with Ruby 3.4, but that seemed unlikely since it's working as expected in other versions.
Thank you
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:120491] [Ruby master Bug#21001] unexpected nil result from proc with ensure and next
2025-01-03 20:10 [ruby-core:120472] [Ruby master Bug#21001] unexpected nil result from proc with ensure and next aharpervc (Andrew Harper) via ruby-core
2025-01-05 0:14 ` [ruby-core:120480] " ydah (Yudai Takada) via ruby-core
@ 2025-01-06 0:57 ` kddnewton (Kevin Newton) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-01-06 0:57 UTC (permalink / raw)
To: ruby-core; +Cc: kddnewton (Kevin Newton)
Issue #21001 has been updated by kddnewton (Kevin Newton).
Assignee set to prism
----------------------------------------
Bug #21001: unexpected nil result from proc with ensure and next
https://bugs.ruby-lang.org/issues/21001#change-111275
* Author: aharpervc (Andrew Harper)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Hello,
I have noticed a different program behavior in Ruby 3.4 compared to previous versions. This is a simplified example for debugging that returns the expected result in Ruby 3.3 but nil in Ruby 3.4
Here is the example program:
``` ruby
puts "Ruby: #{RUBY_VERSION}"
# okay all versions
# RUN_ARRAY = [1]
# fails ruby 3.4 only
RUN_ARRAY = [1,2]
MAP_PROC = Proc.new do |&blk|
block_results = []
RUN_ARRAY.each do |value|
block_value = blk.call(value)
block_results.push block_value
end
block_results
ensure
next block_results
end
test_fn_results = MAP_PROC.call do |value|
break if value > 1
next value
end
puts test_fn_results.inspect
```
For Ruby 3.3.6 the output is:
```
Ruby: 3.3.6
[1]
```
For Ruby 3.4.1 the output is:
```
Ruby: 3.4.1
nil
```
I am expecting the Ruby 3.3 output even for Ruby 3.4. This appears to be a bug, since the program implementation is unchanged. Perhaps there is a bug in the code that is now only showing up with Ruby 3.4, but that seemed unlikely since it's working as expected in other versions.
Thank you
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-06 0:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-03 20:10 [ruby-core:120472] [Ruby master Bug#21001] unexpected nil result from proc with ensure and next aharpervc (Andrew Harper) via ruby-core
2025-01-05 0:14 ` [ruby-core:120480] " ydah (Yudai Takada) via ruby-core
2025-01-06 0:57 ` [ruby-core:120491] " kddnewton (Kevin Newton) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).