[#84280] [Ruby trunk Bug#14181] hangs or deadlocks from waitpid, threads, and trapping SIGCHLD — nobu@...
Issue #14181 has been updated by nobu (Nobuyoshi Nakada).
3 messages
2017/12/15
[#84398] [Ruby trunk Bug#14220] WEBrick changes - failures on MSWIN, MinGW — Greg.mpls@...
Issue #14220 has been reported by MSP-Greg (Greg L).
3 messages
2017/12/22
[#84472] Re: [ruby-dev:50394] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\ — Eric Wong <normalperson@...>
Shouldn't English posts be on ruby-core instead of ruby-dev?
3 messages
2017/12/26
[ruby-core:84390] [Ruby trunk Bug#14215] result_with_hash change local variable by hash value.
From:
ota42y@...
Date:
2017-12-21 10:55:41 UTC
List:
ruby-core #84390
Issue #14215 has been reported by ota42y (ota ota).
----------------------------------------
Bug #14215: result_with_hash change local variable by hash value.
https://bugs.ruby-lang.org/issues/14215
* Author: ota42y (ota ota)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0rc1 (2017-12-14 trunk 61243) [x86_64-darwin16]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
When there is a local variable with the same name as the hash key,
ERB#result_with_hash changes the local variable by hash value.
This is sample code.
~~~ ruby
require "erb"
erb_obj = ERB.new("<%=name%> \"Hello <%=first_name%> <%=last_name%>!\"")
name = 'honoka'
last_name = 'kousaka'
puts erb_obj.result_with_hash(first_name: 'kotori', last_name: 'minami')
puts "Top level name is #{name}, #{last_name}"
user = {first_name: 'umi', last_name: 'sonoda'}
puts erb_obj.result_with_hash(user)
puts "Top level name is #{name}, #{last_name}"
~~~
This code's output is...
~~~
honoka "Hello kotori minami!"
Top level name is honoka, minami # (not honoka, kousaka)
honoka "Hello umi sonoda!"
Top level name is honoka, sonoda # (not honoka, kousaka)
~~~
I think if changes are made within ERB it will be as intended,
but method argument change local variables is an unexpected behavior for user.
(Hash key and variable are completely different concepts...)
I think that the above code should be as follows output.
```
honoka "Hello kotori minami!"
Top level name is honoka, kousaka
honoka "Hello umi sonoda!"
Top level name is honoka, kousaka
```
I write patch it's backup local variable and reset after.
Sorry I don't know how to undefine local valiable so I set nil.
` news.each { |key| b.local_variable_set(key, nil) }`
But there are side effects... please let me know more good code.
---Files--------------------------------
result_with_hash.patch (703 Bytes)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>