Note that your patch has a false positive with the empty string, which is optimized to be always the same object (well, ISTR there are two, a unibyte one and a multibyte one). (byte-compile '(let ((x "")) (eq x ""))) => Warning: `eq' called with literal string that may never match (arg 2) (let ((x "")) (eq x "")) => t