do
if v.must_be_set and not is_set(v) then
_visitor.error(n, "Error: variable '{v}' is possibly unset.")
- else if v.is_typed and stype(v) == null then
- _visitor.error(n, "Error: variable '{v}' is untyped.")
end
end
if _variables.has_key(v) then
return _variables[v]
else
- var t = v.stype
- if t == null then t = visitor.type_object.as_nullable
- var reg = new_register(t)
+ var reg = new_register(v.stype.as(not null))
_variables[v] = reg
return reg
end
# Declaration AST node
readable var _decl: nullable ANode
- # Is the variable correcly declared
- # Return false if typed was not yet computed or
- # if an error occured during the typing computation
- fun is_typed: Bool do return _stype != null
-
- # The declaration static type of the variable
+ # Static type
readable writable var _stype: nullable MMType
redef fun to_s do return _name.to_s
end
end
-redef class VarVariable
- redef readable var _is_typed: Bool = false
-end
###############################################################################
end
else if ne != null then
if not v.check_expr(ne) then return
- va.stype = n_expr.stype
+ va.stype = ne.stype
+ else
+ va.stype = v.type_object.as_nullable
end
- va._is_typed = true
_is_typed = true
end
end
-alt/base_var_untyped_alt2.nit:42,1--2: Error: variable 'b2' is untyped.
+10
+20
+true
+30
+4
+40
-alt/base_var_untyped_alt4.nit:44,1--7: Error: variable 'b2' is untyped.
+alt/base_var_untyped_alt4.nit:44,1--7: Error: Method '+' doesn't exists in nullable Object.
-alt/base_var_untyped_alt5.nit:49,6--7: Error: variable 'b2' is untyped.
+alt/base_var_untyped_alt5.nit:51,3--6: Error: Method '*' doesn't exists in nullable Object.
alt/base_var_untyped_alt6.nit:50,6--7: Error: variable 'b3' is possibly unset.
+alt/base_var_untyped_alt6.nit:51,3--6: Error: Method '*' doesn't exists in nullable Object.
alt/base_var_untyped_alt8.nit:57,5--8: Error: Method or variable 'fail' unknown in Sys.
-alt/base_var_untyped_alt8.nit:58,1: Error: variable 'd' is untyped.