end
end
+redef class Variable
+ # Is the variable must be set before being used ?
+ meth must_be_set: Bool do return false
+end
+
+redef class VarVariable
+ redef meth must_be_set do return true
+end
+
+
+
# Control flow visitor
# * Check reachability in methods
# * Associate breaks and continues
meth check_is_set(n: PNode, v: Variable)
do
- if not control_flow_ctx.is_set(v) then
+ if v.must_be_set and not control_flow_ctx.is_set(v) then
error(n, "Error: variable '{v}' is possibly unset.")
var cfc = control_flow_ctx
while cfc != null do
end
end
-redef class PParam
- redef meth accept_control_flow(v)
- do
- super
- v.mark_is_set(variable)
- end
-end
-
redef class AVardeclExpr
redef meth accept_control_flow(v)
do
special AControlableBlock
end
-redef class AForVardeclExpr
- redef meth accept_control_flow(v)
- do
- super
- v.mark_is_set(variable)
- end
-end
-
-
redef class AVarExpr
redef meth accept_control_flow(v)
do