[#102393] [Ruby master Feature#17608] Compact and sum in one step — sawadatsuyoshi@...

Issue #17608 has been reported by sawa (Tsuyoshi Sawada).

13 messages 2021/02/04

[#102438] [Ruby master Bug#17619] if false foo=42; end creates a foo local variable set to nil — pkmuldoon@...

Issue #17619 has been reported by pkmuldoon (Phil Muldoon).

10 messages 2021/02/10

[#102631] [Ruby master Feature#17660] Expose information about which basic methods have been redefined — tenderlove@...

Issue #17660 has been reported by tenderlovemaking (Aaron Patterson).

9 messages 2021/02/27

[#102639] [Ruby master Misc#17662] The herdoc pattern used in tests does not syntax highlight correctly in many editors — eregontp@...

Issue #17662 has been reported by Eregon (Benoit Daloze).

13 messages 2021/02/27

[#102652] [Ruby master Bug#17664] Behavior of sockets changed in Ruby 3.0 to non-blocking — ciconia@...

Issue #17664 has been reported by ciconia (Sharon Rosner).

23 messages 2021/02/28

[ruby-core:102439] [Ruby master Bug#17619] if false foo=42; end creates a foo local variable set to nil

From: pkmuldoon@...
Date: 2021-02-10 09:37:18 UTC
List: ruby-core #102439
Issue #17619 has been updated by pkmuldoon (Phil Muldoon).


This affects Ruby 2.7.1 and also Ruby 3.0.0. I've not had time to test earlier versions.

----------------------------------------
Bug #17619: if false foo=42; end creates a foo local variable set to nil
https://bugs.ruby-lang.org/issues/17619#change-90322

* Author: pkmuldoon (Phil Muldoon)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Take this following code

```
[1] pry(main)> defined?(foo)
nil

[2] pry(main)> if false
[2] pry(main)*   foo = 42
[2] pry(main)* end  

[3] pry(main)> defined?(foo)
"local-variable"
```

The inner scope inherits the parent scope (ok) but also modifies the parent scope even if the child scope is never entered. A lesser effect of this:

```
[1] pry(main)> defined?(bar)
nil

[2] pry(main)> if false
[2] pry(main)*   bar = 99
[2] pry(main)* end  

[3] pry(main)> defined?(bar)
"local-variable"

[5] pry(main)> bar
99
```

That somewhat lesser affecting because I can just about accept a variable invading the parent scope, and existing after, as a hoisting event. But surely that should not be the case in the negative program-flow case?

The side effects of this are defined?(foo) can't be trusted anymore.

Apologies if this bug has been filed. I did search for it, but couldn't find anything quite matching it. Thanks!



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread