I have a problem with Pari/GP user defined functions making use of user defined functions returning functions. Here is a dumbed-down example:
? f(x) = { (t) -> x + t }
%1 = (x)->(t)->x+t
? g(x) = { local(y); y = f(x); (t) -> y(t) }
%2 = (x)->local(y);y=f(x);(t)->y(t)
? h = g(2)
%3 = (t)->my(x=2);y(t)
? h(1)
*** at top-level: h(1)
*** ^----
*** in function h: y(t)
*** ^----
*** not a function in function call
*** Break loop: type 'break' to go back to GP
I expected to get h(1)=(g(2))(1)=y(1)=(f(2))(1)=3. Am I running into a limitation of first-class functions in Pari, or am I doing something wrong? If the latter, how do I fix it?