Question: error when using variable

mas := proc(f)
return ln(diff(rhs(subs(_C1=0,dsolve(diff(y(x),x) = f))), x$2));
end proc:
mas(exp(x));
mas(mas(exp(x)));
mas(x^2);
mas(x^2+x^3);
 
when i hard code x, there is no problem in above code.
but when i op to get variable x and run below, it do not have problem when run line by line, but it has problem when run in
procedure
Error, (in mas) invalid input: diff received exp(x), which is not valid for its 2nd argument
 
mas := proc(f)
local martin:
martin := op(f):
return ln(diff(rhs(subs(_C1=0,dsolve(diff(y(martin),martin) = f))), martin$2));
end proc:
 
mas(exp(x));
mas(mas(exp(x)));
mas(x^2);
mas(x^2+x^3);
Please Wait...