From: "bughit (bug hit)" Date: 2022-01-06T17:00:24+00:00 Subject: [ruby-core:106986] [Ruby master Feature#18461] closures are capturing unused variables Issue #18461 has been updated by bughit (bug hit). > However, as soon as you call proc.binding.local_variables, you should see all local variables in scope (deoptimizing if necessary) That's not possible. Captured variables are on the heap, uncaptured ones are on the stack and disappear with the stack frame. You can't get them back later. > Otherwise you break backwards compatibility. Which needs to judged against the value of what's being gained. I suspect that dependence on unoptimized capture is not common, important, valuable. ---------------------------------------- Feature #18461: closures are capturing unused variables https://bugs.ruby-lang.org/issues/18461#change-95817 * 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: