@@ -57,13 +57,15 @@ module Ameba::AST
57
57
end
58
58
end
59
59
CRYSTAL
60
- scope = Scope .new nodes.def_nodes.first
60
+
61
61
var_node = nodes.var_nodes.first
62
- scope.add_variable var_node
62
+
63
+ scope = Scope .new nodes.def_nodes.first
64
+ scope.add_variable(var_node)
63
65
scope.inner_scopes << Scope .new(nodes.block_nodes.first, scope)
64
66
65
67
variable = Variable .new(var_node, scope)
66
- variable.reference nodes.var_nodes.first, scope.inner_scopes.first
68
+ variable.reference( nodes.var_nodes.first, scope.inner_scopes.first)
67
69
68
70
scope.references?(variable).should be_true
69
71
end
@@ -77,13 +79,15 @@ module Ameba::AST
77
79
end
78
80
end
79
81
CRYSTAL
80
- scope = Scope .new nodes.def_nodes.first
82
+
81
83
var_node = nodes.var_nodes.first
82
- scope.add_variable var_node
84
+
85
+ scope = Scope .new nodes.def_nodes.first
86
+ scope.add_variable(var_node)
83
87
scope.inner_scopes << Scope .new(nodes.block_nodes.first, scope)
84
88
85
89
variable = Variable .new(var_node, scope)
86
- variable.reference nodes.var_nodes.first, scope.inner_scopes.first
90
+ variable.reference( nodes.var_nodes.first, scope.inner_scopes.first)
87
91
88
92
scope.references?(variable, check_inner_scopes: false ).should be_false
89
93
end
@@ -98,9 +102,11 @@ module Ameba::AST
98
102
end
99
103
end
100
104
CRYSTAL
101
- scope = Scope .new nodes.def_nodes.first
105
+
102
106
var_node = nodes.var_nodes.first
103
- scope.add_variable var_node
107
+
108
+ scope = Scope .new nodes.def_nodes.first
109
+ scope.add_variable(var_node)
104
110
scope.inner_scopes << Scope .new(nodes.block_nodes.first, scope)
105
111
106
112
variable = Variable .new(var_node, scope)
@@ -120,7 +126,7 @@ module Ameba::AST
120
126
describe " #find_variable" do
121
127
it " returns the variable in the scope by name" do
122
128
scope = Scope .new as_node(" foo = 1" )
123
- scope.add_variable Crystal ::Var .new " foo"
129
+ scope.add_variable( Crystal ::Var .new " foo" )
124
130
scope.find_variable(" foo" ).should_not be_nil
125
131
end
126
132
@@ -133,15 +139,15 @@ module Ameba::AST
133
139
describe " #assign_variable" do
134
140
it " creates a new assignment" do
135
141
scope = Scope .new as_node(" foo = 1" )
136
- scope.add_variable Crystal ::Var .new " foo"
142
+ scope.add_variable( Crystal ::Var .new " foo" )
137
143
scope.assign_variable(" foo" , Crystal ::Var .new " foo" )
138
144
var = scope.find_variable(" foo" ).should_not be_nil
139
145
var.assignments.size.should eq 1
140
146
end
141
147
142
148
it " does not create the assignment if variable is wrong" do
143
149
scope = Scope .new as_node(" foo = 1" )
144
- scope.add_variable Crystal ::Var .new " foo"
150
+ scope.add_variable( Crystal ::Var .new " foo" )
145
151
scope.assign_variable(" bar" , Crystal ::Var .new " bar" )
146
152
var = scope.find_variable(" foo" ).should_not be_nil
147
153
var.assignments.size.should eq 0
0 commit comments