Vim's evaluation rules are different than most programming languages. You need to use :execute
in order to evaluate the (function argument) variable; otherwise, it's taken literally (as a buffer name):
execute 'diffget' a:w
PS: Prefer using :normal!
(with !
); this avoids interference from mappings.