clone method Null safety

SymbolTable<T> clone()

Creates a scope identical to this one, but with no children.

The parent scope will see the new scope as a child.

Implementation

SymbolTable<T> clone() {
  var table = SymbolTable<T>();
  table._variables.addAll(_variables);
  table
    .._depth = _depth
    .._parent = _parent
    .._root = _root;
  _parent?._children.add(table);
  return table;
}