def visit_TmpVar(s, node):
        tmpvar_id = (node.name, node.upblk_name)
        if tmpvar_id not in s.tmpvars:
            # This tmpvar is being created. Later when it is used, its type can
            # be read from the tmpvar type environment.
            node.Type = rt.NoneType()

        else:
            node.Type = s.tmpvars[tmpvar_id]
  def _visit_Assign_single_target( s, node, target, i ):
    rhs_type = node.value.Type
    lhs_type = target.Type

    if isinstance( target, bir.TmpVar ):
      tmpvar_id = (target.name, target.upblk_name)
      if lhs_type != rt.NoneType() and lhs_type.get_dtype() != rhs_type.get_dtype():
        raise PyMTLTypeError( s.blk, node.ast,
          f'conflicting type {rhs_type} for temporary variable {node.targets[i].name}(LHS target#{i} of {lhs_type})!' )

      # Creating a temporaray variable
      # Reminder that a temporary variable is essentially a wire. So we use
      # rt.Wire here instead of rt.NetWire
      target.Type = rt.Wire( rhs_type.get_dtype() )
      s.tmpvars[ tmpvar_id ] = rt.Wire( rhs_type.get_dtype() )

    else:
      # non-temporary assignment is an L1 thing
      super()._visit_Assign_single_target( node, target, i )
    def visit_Assign(s, node):
        # RHS should have the same type as LHS
        rhs_type = node.value.Type
        lhs_type = node.target.Type

        if isinstance(node.target, bir.TmpVar):
            tmpvar_id = (node.target.name, node.target.upblk_name)
            if lhs_type != rt.NoneType() and lhs_type.get_dtype(
            ) != rhs_type.get_dtype():
                raise PyMTLTypeError(
                    s.blk, node.ast,
                    f'conflicting type {rhs_type} for temporary variable {node.target.name}({lhs_type})!'
                )

            # Creating a temporaray variable
            # Reminder that a temporary variable is essentially a wire. So we use
            # rt.Wire here instead of rt.NetWire
            node.target.Type = rt.Wire(rhs_type.get_dtype())
            s.tmpvars[tmpvar_id] = rt.Wire(rhs_type.get_dtype())
            node.Type = None

        else:
            # non-temporary assignment is an L1 thing
            super().visit_Assign(node)