The shell "trap" builtin isn't registering a function, it's a delayed "eval".
(Not many of you are currently writing your own bash replacement shell, so this observation is presumably of limited utility, but it's a thing I need to remember for morning.)