From: "bughit (bug hit)" Date: 2022-01-06T23:13:11+00:00 Subject: [ruby-core:106992] [Ruby master Feature#18461] closures are capturing unused variables Issue #18461 has been updated by bughit (bug hit). > That's of no use then, that's just not the semantics of Proc#binding, which is to capture every variable at the place the block is defined. If you are suggesting that everything is set in stone, that's obviously false. Changes can be justified when not catastrophically disruptive and when the benefits outweigh the disruption. > Hence Proc#binding would need to be removed There no logic in this conclusion. Returning a binding that represents what the proc actually captures is not worse than having no binding. > The block could also use eval V8 handles that, detecting eval and deopting, so ruby can too. > but I think one that would need to significantly change Ruby semantics to be feasible without breaking many things. "Significantly" is an overstatement. What many things will it break? Taking a dependency on procs capturing variables they don't use, does not seem like a realistic and common use case. ---------------------------------------- Feature #18461: closures are capturing unused variables https://bugs.ruby-lang.org/issues/18461#change-95823 * Author: bughit (bug hit) * Status: Open * Priority: Normal ---------------------------------------- ```rb def foo a = 1 ->{} end p foo.binding.local_variables # [:a] ``` Shouldn't `a` be optimized away? Like v8 does (https://bugs.chromium.org/p/v8/issues/detail?id=3491) -- https://bugs.ruby-lang.org/ Unsubscribe: