ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:95161] [Ruby master Misc#16192] ENV.update hash values ignored when block given
       [not found] <redmine.issue-16192.20190930221227@ruby-lang.org>
@ 2019-09-30 22:12 ` burdettelamar
  2019-09-30 23:18 ` [ruby-core:95163] " shevegen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: burdettelamar @ 2019-09-30 22:12 UTC (permalink / raw)
  To: ruby-core

Issue #16192 has been reported by burdettelamar@yahoo.com (Burdette Lamar).

----------------------------------------
Misc #16192: ENV.update hash values ignored when block given
https://bugs.ruby-lang.org/issues/16192

* Author: burdettelamar@yahoo.com (Burdette Lamar)
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Doc:

update(hash) → Hash
update(hash) { |name, old_value, new_value| block } → Hash

Adds the contents of hash to the environment variables. If no block is specified entries with duplicate keys are overwritten, otherwise the value of each duplicate name is determined by calling the block with the key, its value from the environment and its value from the hash.

But:

The attached code shows that the block is called and its returned value assigned even if the name is not a duplicate.  So basically this means that when a block is given, the hash values are ignored for all keys.

I had expected that for a non-duplicate name, the block would be ignored, and the hash value assigned.

I'm calling this a Misc, and not a Bug, just in case I'm missing something.

---Files--------------------------------
t.rb (179 Bytes)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:95163] [Ruby master Misc#16192] ENV.update hash values ignored when block given
       [not found] <redmine.issue-16192.20190930221227@ruby-lang.org>
  2019-09-30 22:12 ` [ruby-core:95161] [Ruby master Misc#16192] ENV.update hash values ignored when block given burdettelamar
@ 2019-09-30 23:18 ` shevegen
  2019-10-01  3:24 ` [ruby-core:95165] " nobu
  2019-11-30 17:18 ` [ruby-core:96038] [Ruby master Bug#16192] " eregontp
  3 siblings, 0 replies; 4+ messages in thread
From: shevegen @ 2019-09-30 23:18 UTC (permalink / raw)
  To: ruby-core

Issue #16192 has been updated by shevegen (Robert A. Heiler).


I can not say whether it is a bug or not, but I believe that either way,
it would be good to mention, in the documentation, which behaviour is to
be expected e. g. for the example you gave:

    ENV.update('foo' => 'value_from_hash') { |name, old, new| 'value_from_block' }

If I understood the behaviour correctly then the block has a higher priority than
the (first) argument to .update(). Again, no idea if this is a bug or the
desired behaviour, but I think it would help if the documentation could
specify this and perhaps add a few examples to quickly demonstrate the use of
the method.

(Here is the link I used, if anyone else wants to look at it quickly: 
https://ruby-doc.org/core-2.6.4/ENV.html#method-c-update )

----------------------------------------
Misc #16192: ENV.update hash values ignored when block given
https://bugs.ruby-lang.org/issues/16192#change-81800

* Author: burdettelamar@yahoo.com (Burdette Lamar)
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Doc:

update(hash) → Hash
update(hash) { |name, old_value, new_value| block } → Hash

Adds the contents of hash to the environment variables. If no block is specified entries with duplicate keys are overwritten, otherwise the value of each duplicate name is determined by calling the block with the key, its value from the environment and its value from the hash.

But:

The attached code shows that the block is called and its returned value assigned even if the name is not a duplicate.  So basically this means that when a block is given, the hash values are ignored for all keys.

I had expected that for a non-duplicate name, the block would be ignored, and the hash value assigned.

I'm calling this a Misc, and not a Bug, just in case I'm missing something.

---Files--------------------------------
t.rb (179 Bytes)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:95165] [Ruby master Misc#16192] ENV.update hash values ignored when block given
       [not found] <redmine.issue-16192.20190930221227@ruby-lang.org>
  2019-09-30 22:12 ` [ruby-core:95161] [Ruby master Misc#16192] ENV.update hash values ignored when block given burdettelamar
  2019-09-30 23:18 ` [ruby-core:95163] " shevegen
@ 2019-10-01  3:24 ` nobu
  2019-11-30 17:18 ` [ruby-core:96038] [Ruby master Bug#16192] " eregontp
  3 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2019-10-01  3:24 UTC (permalink / raw)
  To: ruby-core

Issue #16192 has been updated by nobu (Nobuyoshi Nakada).

Description updated

I think this is a bug, for the same reason as [Bug #16173].

https://github.com/ruby/ruby/pull/2512

----------------------------------------
Misc #16192: ENV.update hash values ignored when block given
https://bugs.ruby-lang.org/issues/16192#change-81802

* Author: burdettelamar@yahoo.com (Burdette Lamar)
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Doc:

```
update(hash) → Hash
update(hash) { |name, old_value, new_value| block } → Hash
```

Adds the contents of hash to the environment variables. If no block is specified entries with duplicate keys are overwritten, otherwise the value of each duplicate name is determined by calling the block with the key, its value from the environment and its value from the hash.

But:

The attached code shows that the block is called and its returned value assigned even if the name is not a duplicate.  So basically this means that when a block is given, the hash values are ignored for all keys.

I had expected that for a non-duplicate name, the block would be ignored, and the hash value assigned.

I'm calling this a Misc, and not a Bug, just in case I'm missing something.

---Files--------------------------------
t.rb (179 Bytes)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:96038] [Ruby master Bug#16192] ENV.update hash values ignored when block given
       [not found] <redmine.issue-16192.20190930221227@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-10-01  3:24 ` [ruby-core:95165] " nobu
@ 2019-11-30 17:18 ` eregontp
  3 siblings, 0 replies; 4+ messages in thread
From: eregontp @ 2019-11-30 17:18 UTC (permalink / raw)
  To: ruby-core

Issue #16192 has been updated by Eregon (Benoit Daloze).

Backport set to 2.5: UNKNOWN, 2.6: UNKNOWN
Tracker changed from Misc to Bug

This is a clear bug, I'll merge @nobu's patch.
There are already specs for this from https://github.com/ruby/spec/pull/714, which I'll synchronize to MRI soon.

----------------------------------------
Bug #16192: ENV.update hash values ignored when block given
https://bugs.ruby-lang.org/issues/16192#change-82887

* Author: burdettelamar@yahoo.com (Burdette Lamar)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Doc:

```
update(hash) → Hash
update(hash) { |name, old_value, new_value| block } → Hash
```

Adds the contents of hash to the environment variables. If no block is specified entries with duplicate keys are overwritten, otherwise the value of each duplicate name is determined by calling the block with the key, its value from the environment and its value from the hash.

But:

The attached code shows that the block is called and its returned value assigned even if the name is not a duplicate.  So basically this means that when a block is given, the hash values are ignored for all keys.

I had expected that for a non-duplicate name, the block would be ignored, and the hash value assigned.

I'm calling this a Misc, and not a Bug, just in case I'm missing something.

---Files--------------------------------
t.rb (179 Bytes)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-30 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16192.20190930221227@ruby-lang.org>
2019-09-30 22:12 ` [ruby-core:95161] [Ruby master Misc#16192] ENV.update hash values ignored when block given burdettelamar
2019-09-30 23:18 ` [ruby-core:95163] " shevegen
2019-10-01  3:24 ` [ruby-core:95165] " nobu
2019-11-30 17:18 ` [ruby-core:96038] [Ruby master Bug#16192] " eregontp

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 read-only IMAP folder(s) and NNTP newsgroup(s).