Skip to content

Commit 9fd7f28

Browse files
authored
Merge pull request #55 from ruby/shareable_constant_completion
Support completion of code including ShareableConstantNode
2 parents ec56f99 + b07e3da commit 9fd7f28

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/repl_type_completor/type_analyzer.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ def evaluate_lambda_node(node, scope)
447447
Types::PROC
448448
end
449449

450+
def evaluate_shareable_constant_node(node, scope)
451+
evaluate(node.write, scope)
452+
end
453+
450454
def evaluate_reference_write(node, scope)
451455
scope[node.name.to_s] = evaluate node.value, scope
452456
end

test/repl_type_completor/test_type_analyze.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@ def test_opwrite
642642
assert_call('Array::A=1; Array::A&&=1.0; Array::A.', include: Float)
643643
end
644644

645+
def test_shareable_constant_value
646+
assert_call("#shareable_constant_value:literal\nA=1; A.", include: Integer)
647+
end
648+
645649
def test_case_when
646650
assert_call('case x; when A; 1; when B; 1.0; end.', include: [Integer, Float, NilClass])
647651
assert_call('case x; when A; 1; when B; 1.0; else; 1r; end.', include: [Integer, Float, Rational], exclude: NilClass)

0 commit comments

Comments
 (0)