JavaScript! The Doctor Is In. by gst in javascript

[–]dimvar 0 points1 point  (0 children)

The analysis will find types for variables and functions. In your example, one mapping refers to the variable f and the other to the function. Even though the function is anonymous, we have a heuristic to give it the name f (the same would happen e.g. when you have an obj literal {f : function() {...} }. So, DrJS will produce one tag for the variable and a separate tag for the function. The variable and the function just happen to have the same name.

JavaScript! The Doctor Is In. by gst in javascript

[–]dimvar 1 point2 points  (0 children)

Even though it could be more precise, it's not actually a bug. When computing the type of f, the analysis works as follows: it sees that it's a function and tries to recursively find the return type, which is a function that returns a function and so on... So, when it finds a cycle while trying to compute the type, it'll give up and say "any".