# Buggy code
def merge(
    self,
    other: "CoercibleMapping",
    inplace: bool = None,
    overwrite_vars: Union[Hashable, Iterable[Hashable]] = frozenset(),
    compat: str = "no_conflicts",
    join: str = "outer",
    fill_value: Any = dtypes.NA,
) -> "Dataset":
    """Merge the arrays of two datasets into a single dataset.

    This method generally does not allow for overriding data, with the
    exception of attributes, which are ignored on the second dataset.
    Variables with the same name are checked for conflicts via the equals
    or identical methods.

    Parameters
    ----------
    other : Dataset or castable to Dataset
        Dataset or variables to merge with this dataset.
    overwrite_vars : Hashable or iterable of Hashable, optional
        If provided, update variables of these name(s) without checking for
        conflicts in this dataset.
    compat : {'broadcast_equals', 'equals', 'identical',
              'no_conflicts'}, optional
        String indicating how to compare variables of the same name for
        potential conflicts:

        - 'broadcast_equals': all values must be equal when variables are
          broadcast against each other to ensure common dimensions.
        - 'equals': all values and dimensions must be the same.
        - 'identical': all values, dimensions and attributes must be the
          same.
        - 'no_conflicts': only values which are not null in both datasets
          must be equal. The returned dataset then contains the combination
          of all non-null values.

    join : {'outer', 'inner', 'left', 'right', 'exact'}, optional
        Method for joining ``self`` and ``other`` along shared dimensions:

        - 'outer': use the union of the indexes
        - 'inner': use the intersection of the indexes
        - 'left': use indexes from ``self``
        - 'right': use indexes from ``other``
        - 'exact': error instead of aligning non-equal indexes
    fill_value: scalar, optional
        Value to use for newly missing values

    Returns
    -------
    merged : Dataset
        Merged dataset.

    Raises
    ------
    MergeError
        If any variables conflict (see ``compat``).
    """
    _check_inplace(inplace)
    merge_result = dataset_merge_method(
        self,
        other,
        overwrite_vars=overwrite_vars,
        compat=compat,
        join=join,
        fill_value=fill_value,
    )
    return self._replace(**merge_result._asdict())


# Traceback (AttributeError)
<xarray.Dataset>
Dimensions:  ()
Data variables:
a        int64 0
b        int64 1

Traceback (most recent call last):
File "mwe.py", line 6, in <module>
actual = ds.merge(da)
File "/home/tegn500/Documents/Work/Code/xarray/xarray/core/dataset.py", line 3591, in merge
fill_value=fill_value,
File "/home/tegn500/Documents/Work/Code/xarray/xarray/core/merge.py", line 835, in dataset_merge_method
objs, compat, join, priority_arg=priority_arg, fill_value=fill_value
File "/home/tegn500/Documents/Work/Code/xarray/xarray/core/merge.py", line 548, in merge_core
coerced = coerce_pandas_values(objects)
File "/home/tegn500/Documents/Work/Code/xarray/xarray/core/merge.py", line 394, in coerce_pandas_values
for k, v in obj.items():
File "/home/tegn500/Documents/Work/Code/xarray/xarray/core/common.py", line 233, in __getattr__
"{!r} object has no attribute {!r}".format(type(self).__name__, name)
AttributeError: 'DataArray' object has no attribute 'items'

# Fixed code
def merge(
    self,
    other: "CoercibleMapping",
    inplace: bool = None,
    overwrite_vars: Union[Hashable, Iterable[Hashable]] = frozenset(),
    compat: str = "no_conflicts",
    join: str = "outer",
    fill_value: Any = dtypes.NA,
) -> "Dataset":
    """Merge the arrays of two datasets into a single dataset.

    This method generally does not allow for overriding data, with the
    exception of attributes, which are ignored on the second dataset.
    Variables with the same name are checked for conflicts via the equals
    or identical methods.

    Parameters
    ----------
    other : Dataset or castable to Dataset
        Dataset or variables to merge with this dataset.
    overwrite_vars : Hashable or iterable of Hashable, optional
        If provided, update variables of these name(s) without checking for
        conflicts in this dataset.
    compat : {'broadcast_equals', 'equals', 'identical',
              'no_conflicts'}, optional
        String indicating how to compare variables of the same name for
        potential conflicts:

        - 'broadcast_equals': all values must be equal when variables are
          broadcast against each other to ensure common dimensions.
        - 'equals': all values and dimensions must be the same.
        - 'identical': all values, dimensions and attributes must be the
          same.
        - 'no_conflicts': only values which are not null in both datasets
          must be equal. The returned dataset then contains the combination
          of all non-null values.

    join : {'outer', 'inner', 'left', 'right', 'exact'}, optional
        Method for joining ``self`` and ``other`` along shared dimensions:

        - 'outer': use the union of the indexes
        - 'inner': use the intersection of the indexes
        - 'left': use indexes from ``self``
        - 'right': use indexes from ``other``
        - 'exact': error instead of aligning non-equal indexes
    fill_value: scalar, optional
        Value to use for newly missing values

    Returns
    -------
    merged : Dataset
        Merged dataset.

    Raises
    ------
    MergeError
        If any variables conflict (see ``compat``).
    """
    _check_inplace(inplace)
    other = other.to_dataset() if isinstance(other, xr.DataArray) else other
    merge_result = dataset_merge_method(
        self,
        other,
        overwrite_vars=overwrite_vars,
        compat=compat,
        join=join,
        fill_value=fill_value,
    )
    return self._replace(**merge_result._asdict())