From a09f764ce52838a363b006ea434287eca431dbae Mon Sep 17 00:00:00 2001 From: tomoya ishida Date: Tue, 18 Oct 2022 14:44:04 +0900 Subject: [ruby/irb] Always use local variables in current context to parse code (https://github.com/ruby/irb/pull/397) * Use local_variables for colorize, code_block_open check, nesting_level and assignment_expression check * Check if expression is an assignment BEFORE evaluating it. evaluate might define new localvars and change result of assignment_expression? * Add local_variables dependent code test * pend local variable dependent test on truffleruby code_block_open is not working on truffleruby * Always pass context to RubyLex#lex * Rename local_variable_assign_code generator method name * Add assignment expression truncate test * Add Context#local_variables and make generate_local_variables_assign_code more simple * Update lib/irb/input-method.rb Co-authored-by: Stan Lo * Add a comment why assignment expression check should be done before evaluate https://github.com/ruby/irb/commit/c8b3877281 Co-authored-by: Stan Lo Co-authored-by: Takashi Kokubun --- lib/irb/context.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/irb/context.rb') diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 5e07f5dfb0..d238da9350 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -518,5 +518,9 @@ module IRB end alias __to_s__ to_s alias to_s inspect + + def local_variables # :nodoc: + workspace.binding.local_variables + end end end -- cgit v1.2.3