Had similar situation. It was caused by a pointer overrun [ran off the edge of an array!]. That bricked it, I guess because it messed up the USB internals such that the XIAO couldn’t connect/communicate with my desktop PC [running Arduino IDE].
So, what I did was [and I tried this over and over around 5 times], I disconnected the the USB cable, then I did a Ctrl-U to get the compiler going, then I hurriedly reconnected USB to the XIAO. I tried changing the timing slightly each time, until finally I got it to upload!
My working theory was, based on the USB connect/disconnect musical tones that Windows issues to indicate USB connection status, It sounded like, after connecting the USB cable, a connection was happening, then moments later, it disconnected – probably because of the code crash. When I managed to get the timing such that the upload started BEFORE the code crash, it could happen, because having a good connection, the Arduino IDE was able to issue a reset, preventing the crash incident, so the upload could start!!
Don’t know if that’s true, or not, but by golly it worked!! Which is good, in my case, because the XIAO is sealed inside a selenite tower!!! Whew!!!
UPDATE: This also works [for me at least]: Ctrl-U, unplug USB and wait for Dee-Doo-Dum, plug back in!
Also, it helps to place a long delay – like 5 seconds – in the Setup() function.
[“indent preformatted text by 4 spaces” … NOT!]