Issue #18125 has been updated by byroot (Jean Boussier).


It is excepted because of variable hoisting.

Same reason why `foo = 1 unless foo` works.


----------------------------------------
Misc #18125: A strange behavior when same name variable/method coexist issue.
https://bugs.ruby-lang.org/issues/18125#change-93450

* Author: zw963 (Wei Zheng)
* Status: Open
* Priority: Normal
----------------------------------------
Following is a example.

## Reproduce

```rb
def deploy_to
  "deploy_to"
end

deploy_to = "#{deploy_to} new place"

p defined? deploy_to # => local_varible
p deploy_to  # => " new place"
```

## What we expected.

```rb
def deploy_to
  "deploy_to"
end

deploy_to = "#{deploy_to} new place"

p defined? deploy_to # => local_varible
p deploy_to  # => "deploy_to new place"
```


This strange behavior i found it after several years ruby programming.

Perhaps this is always the expected behavior?

i report here for check anyway





-- 
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>