That reminds me of a famous incident where a circus elephant named Mary was hanged by the neck until dead for committing murder on a human. She got angry at her human handler for prodding her and stomped him. See https://ancillary-proxy.atarimworker.io?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMary_(elephant) for the details and a pic of Mary's hanging. I don't think she got to defend herself in a court of law, though.
My two cents on the subject is I think the law could accommodate intelligent animals, but each species should probably be treated differently based on their nature and capabilities. I don't think treating them as persons is the right idea.
Old programmers never die, they just branch to a new address.