Actually there are other problems that are caused by the fact that you're not really doing HOAS, but something even more difficult, namely trying to infer the function by passing in values.
For example
LJSON.stringify(function(v) { if (v == 0) { return "zero"; } else { return "one"; } })
Evaluates to the string (function(v0){return "one"})
The only way to avoid both these issues, is to inspect the code of a function f using f.toString(). However you would need to consider the scope where f was defined.