parser: node locations are not nullable
[nit.git] / src / parser / parser_nodes.nit
index c9fde5e..36c5ceb 100644 (file)
@@ -23,7 +23,10 @@ import mmloader
 
 # Root of the AST hierarchy
 abstract class ANode
-       readable var _location: nullable Location
+       var _location: nullable Location
+       # Location is set during AST building. Once built, location cannon be null
+       # However, manual instanciated nodes may need mode care
+       fun location: Location do return _location.as(not null)
 end
 
 # Ancestor of all tokens
@@ -34,7 +37,7 @@ end
 # Ancestor of all productions
 abstract class Prod
 special ANode
-       fun location=(loc: nullable Location) do _location = loc
+       fun location=(l: Location) do _location = l
 end
 class TEol
 special Token