From: "tompng (tomoya ishida) via ruby-core" Date: 2024-12-19T09:33:14+00:00 Subject: [ruby-core:120326] [Ruby master Bug#20965] `it` vs `binding.local_variables` Issue #20965 has been updated by tompng (tomoya ishida). I have a concern of making `it` parameter an lvar. ~~~ruby 1| 42.tap do 2| p binding.local_variable_get('it') 3| it /1/i 4| p it 5| end ~~~ When parser reads `p it` at line 4, `it` turns out to be a local variable, I think from the beginning of the block(from line 2). But on line 3, `it /1/i` is already parsed as if lvar `it` does not exist. It is impossible to re-parse the block again, so the original implementation(it parameter is not an lvar) makes sense to me. ---------------------------------------- Bug #20965: `it` vs `binding.local_variables` https://bugs.ruby-lang.org/issues/20965#change-111096 * Author: zverok (Victor Shepelev) * Status: Closed * ruby -v: ruby 3.4.0dev (2024-12-15T13:36:38Z master 366fd9642f) +PRISM [x86_64-linux] * Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED ---------------------------------------- `it` is not available in the list of `binding.local_varaibles`, **unlike** numbered parameters: ```ruby p(proc { binding.local_variables }.call) # [] p(proc { |x| binding.local_variables }.call) # [:x] p(proc { _1; binding.local_variables }.call) # [:_1] p(proc { vars = binding.local_variables; _1; vars }.call) # [:_1, :vars] p(proc { it; binding.local_variables }.call) # [] ``` I wonder if it is deliberate or accidental. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/