nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
online_ide: imports nitc (symlinked from contrib)
[nit.git]
/
src
/
semantize
/
local_var_init.nit
diff --git
a/src/semantize/local_var_init.nit
b/src/semantize/local_var_init.nit
index
4b9a4ab
..
27c7ddd
100644
(file)
--- a/
src/semantize/local_var_init.nit
+++ b/
src/semantize/local_var_init.nit
@@
-15,12
+15,13
@@
# limitations under the License.
# Verify that local variables are initialized before their usage
# limitations under the License.
# Verify that local variables are initialized before their usage
-# Require that the scope and the flow analaysis are already performed
+# Require that the scope and the flow analysis are already performed
module local_var_init
import flow
redef class ToolContext
module local_var_init
import flow
redef class ToolContext
+ # Run `APropdef::do_local_var_init` on each propdef
var local_var_init_phase: Phase = new LocalVarInitPhase(self, [flow_phase])
end
var local_var_init_phase: Phase = new LocalVarInitPhase(self, [flow_phase])
end
@@
-44,12
+45,7
@@
private class LocalVarInitVisitor
var toolcontext: ToolContext
var toolcontext: ToolContext
- init(toolcontext: ToolContext)
- do
- self.toolcontext = toolcontext
- end
-
- # Local variables that are possibily unset (ie local variable without an initial value)
+ # Local variables that are possibly unset (ie local variable without an initial value)
var maybe_unset_vars: Set[Variable] = new HashSet[Variable]
fun mark_is_unset(node: AExpr, variable: nullable Variable)
var maybe_unset_vars: Set[Variable] = new HashSet[Variable]
fun mark_is_unset(node: AExpr, variable: nullable Variable)
@@
-74,8
+70,8
@@
private class LocalVarInitVisitor
var flow = node.after_flow_context.as(not null)
if not flow.is_variable_set(variable) then
var flow = node.after_flow_context.as(not null)
if not flow.is_variable_set(variable) then
- self.toolcontext.error(node.hot_location, "Error: variable '{variable}' is possibly unset.")
- # Remove the variable to avoid repetting errors
+ self.toolcontext.error(node.hot_location, "Error: possibly unset variable `{variable}`.")
+ # Remove the variable to avoid repeating errors
self.maybe_unset_vars.remove(variable)
end
end
self.maybe_unset_vars.remove(variable)
end
end
@@
-116,7
+112,7
@@
redef class AVardeclExpr
super
# The variable is unset only if there is no initial value.
super
# The variable is unset only if there is no initial value.
- # Note: loops in inital value are not a problem
+ # Note: loops in initial value are not a problem
# Example:
#
# var foo = foo + 1 #-> Error during typing: "self.foo" unknown
# Example:
#
# var foo = foo + 1 #-> Error during typing: "self.foo" unknown