def join(list1, list2,
             separator = identifier("auto"), bracketed = identifier("auto"),
             kwargs = nil, *rest)
      if separator.is_a?(Hash)
        kwargs = separator
        separator = identifier("auto")
      elsif bracketed.is_a?(Hash)
        kwargs = bracketed
        bracketed = identifier("auto")
      elsif rest.last.is_a?(Hash)
        rest.unshift kwargs
        kwargs = rest.pop
      end

      unless rest.empty?
        # Add 4 to rest.length because we don't want to count the kwargs hash,
        # which is always passed.
        raise ArgumentError.new("wrong number of arguments (#{rest.length + 4} for 2..4)")
      end

      if kwargs
        separator = kwargs.delete("separator") || separator
        bracketed = kwargs.delete("bracketed") || bracketed

        unless kwargs.empty?
          name, val = kwargs.to_a.first
          raise ArgumentError.new("Unknown argument $#{name} (#{val})")
        end
      end

      assert_type separator, :String, :separator
      unless %w(auto space comma).include?(separator.value)
        raise ArgumentError.new("Separator name must be space, comma, or auto")
      end

      list(list1.to_a + list2.to_a,
        separator:
          if separator.value == 'auto'
            list1.separator || list2.separator || :space
          else
            separator.value.to_sym
          end,
        bracketed:
          if bracketed.is_a?(Sass::Script::Value::String) && bracketed.value == 'auto'
            list1.bracketed
          else
            bracketed.to_bool
          end)
    end
def join(list1, list2,
             separator = identifier("auto"), bracketed = identifier("auto"),
             kwargs = nil, *rest)
      if separator.is_a?(Hash)
        kwargs = separator
        separator = identifier("auto")
      elsif bracketed.is_a?(Hash)
        kwargs = bracketed
        bracketed = identifier("auto")
      elsif rest.last.is_a?(Hash)
        rest.unshift kwargs
        kwargs = rest.pop
      end

      unless rest.empty?
        # Add 4 to rest.length because we don't want to count the kwargs hash,
        # which is always passed.
        raise ArgumentError.new("wrong number of arguments (#{rest.length + 4} for 2..4)")
      end

      if kwargs
        separator = kwargs.delete("separator") || separator
        bracketed = kwargs.delete("bracketed") || bracketed

        unless kwargs.empty?
          name, val = kwargs.to_a.first
          raise ArgumentError.new("Unknown argument $#{name} (#{val})")
        end
      end

      assert_type separator, :String, :separator
      unless %w(auto space comma).include?(separator.value)
        raise ArgumentError.new("Separator name must be space, comma, or auto")
      end

      list(list1.to_a + list2.to_a,
        separator:
          if separator.value == 'auto'
            list1.separator || list2.separator || :space
          else
            separator.value.to_sym
          end,
        bracketed:
          if bracketed.is_a?(Sass::Script::Value::String) && bracketed.value == 'auto'
            list1.bracketed
          else
            bracketed.to_bool
          end)
    end
Joins together two lists into one.

 Unless `$separator` is passed, if one list is comma-separated and one is
 space-separated, the first parameter's separator is used for the resulting
 list. If both lists have fewer than two items, spaces are used for the
 resulting list.

 Unless `$bracketed` is passed, the resulting list is bracketed if the
 first parameter is.

 Like all list functions, `join()` returns a new list rather than modifying
 its arguments in place.

 @example
   join(10px 20px, 30px 40px) => 10px 20px 30px 40px
   join((blue, red), (#abc, #def)) => blue, red, #abc, #def
   join(10px, 20px) => 10px 20px
   join(10px, 20px, comma) => 10px, 20px
   join((blue, red), (#abc, #def), space) => blue red #abc #def
   join([10px], 20px) => [10px 20px]
 @overload join($list1, $list2, $separator: auto, $bracketed: auto)
   @param $list1 [Sass::Script::Value::Base]
   @param $list2 [Sass::Script::Value::Base]
   @param $separator [Sass::Script::Value::String] The list separator to use.
     If this is `comma` or `space`, that separator will be used. If this is
     `auto` (the default), the separator is determined as explained above.
   @param $bracketed [Sass::Script::Value::Base] Whether the resulting list
     will be bracketed. If this is `auto` (the default), the separator is
     determined as explained above.
 @return [Sass::Script::Value::List]