parser: node locations are not nullable
[nit.git] / src / parser / xss / nodes.xss
index 9cd1919..d6df697 100644 (file)
@@ -18,7 +18,11 @@ $ // limitations under the License.
 $ template make_abs_nodes()
 # Root of the AST hierarchy
 abstract class PNode
-       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
@@ -29,7 +33,7 @@ end
 # Ancestor of all productions
 abstract class Prod
 special PNode
-       fun location=(loc: nullable Location) do _location = loc
+       fun location=(loc: Location) do _location = loc
 end
 $ end template