When using @r as a selector, you cannot use the name of the mob without the type of mob to select.
To reproduce
1.spawn a named mob.
2. use @r in any command with only the name specified. The output will be an error.
3. use the same command, but with the mob type specified, which should work. unlike without the mob type.
In my screen shots, The creeper is named "Queen"
@r only select player unless type= is set