I put this in chat with chosen mobs around
function name:name if @e[name=name]
Pretty sure that worked
When I put this into a function:
execute @s ~ ~ ~ function name:name if @e[name=name]
it wouldn't work because there was more than 1 mob that had been found by the selector
(If you've seen my last bug report you'd understand why I added the execute thing)
https://bugs.mojang.com/browse/MC-117661