I can at least verify that it's an issue on 5.18. And the code looks reasonable to me. Of course on 5.18 I also get:
Smartmatch is experimental at ./mytest.pl line 4.
Smartmatch is experimental at ./mytest.pl line 6.
You might search the bug queue for issues related to smartmatch to see if it's already been reported. If not, go for it. I think the operator is in a state of flux, but it would be a shame for little things like this to not get fixed if the operator ever has its experimental designation removed again.