<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_type_spec(self, name, spec, lineno):
 """Adds the given type to the scope. :param str name: Name of the new type :param spec: ``TypeSpec`` object containing information on the type, or a ``TypeReference`` if this is meant to be resolved during the ``link`` stage. :param lineno: Line number on which this type is defined. """

        assert type is not None

        if name in self.type_specs:
            raise ThriftCompilerError(
                'Cannot define type "%s" at line %d. '
                'Another type with that name already exists.'
                % (name, lineno)
            )

        self.type_specs[name] = spec