GetFormula unexpected error

Hi all, I am receiving a weird error that I can't understand:

function printFormula(wave w)
  //a valid wave is passed in at the call

  string s = getFormula(w) // <--Throws execution error 'expected wave or variable'

  print s
end

I don't understand why getFormula() is throwing an error here. If I enter the same code on the execution line of the debugger (or even on the command line) it works fine.

I can confirm, at least on IP9 and Mac OS. IP7 and 8 seem to work as expected. 

It works correctly in a function only if the parameter name exactly matches the wave name.

This is true all the way back to Igor 6!

I'm working on a fix to Igor 9 (Igor 8 is no longer being updated, sorry)

A workaround is to get the wave's full path and use $:

function printFormula(wave w)
  String path=GetWavesDataFolder(w,2)
  string s = getFormula($path)
  print s
end