Why ALTER DATABASE .. MODIFY NAME reports an error while succeeding at the same time? I am running the following query in SSMS:

SET NOCOUNT ON
ALTER DATABASE [xyz] MODIFY NAME = [xyz_]


And get this:

The database name 'xyz_' has been set.
Msg 911, Level 16, State 1, Line 2
Database 'xyz' does not exist. Make sure that the name is entered correctly.


So, the query fails, but the database is still renamed!

What is going on?
One possibility is that there's a DDL trigger that fires for ALTER DATABASE, and that trigger code try to refer to the (now old) database name.