Skip to content

Scan functions inside of initializers or function calls#64

Merged
bobbylight merged 5 commits into
bobbylight:masterfrom
OndrejSpanel:functions_in_expressions
Jun 18, 2025
Merged

Scan functions inside of initializers or function calls#64
bobbylight merged 5 commits into
bobbylight:masterfrom
OndrejSpanel:functions_in_expressions

Conversation

@OndrejSpanel
Copy link
Copy Markdown
Contributor

Functions inside of initializers or function calls (and maybe in other positions as well) are currently ignored.

Such functions, passed as callbacks, are common is some JS enviroments.

First commit adds handling for functions defined in variable initializers, like this:

var f = function (s) {
  var something = s.compute()
};

I hope to be able to handle at least following scenario as well:

call(function (s) {
  var something = s.compute()
});

@OndrejSpanel
Copy link
Copy Markdown
Contributor Author

I hope to be able to handle at least following scenario as well:

Should be done:

image

@OndrejSpanel
Copy link
Copy Markdown
Contributor Author

A few more:

  • function used in a return statement:
function (s) {
   return function (www) {
      var localInReturn;
   };
   
})(0);

image

  • function in IIFE:
(function (x) {
   var localInIIFE;
   
})(0);

image

@OndrejSpanel OndrejSpanel force-pushed the functions_in_expressions branch from adbd9b6 to 93b57cd Compare June 17, 2025 06:22
@OndrejSpanel OndrejSpanel marked this pull request as ready for review June 17, 2025 06:22
@OndrejSpanel
Copy link
Copy Markdown
Contributor Author

I do not have intention working on this any further. I think even in current state it is an improvement and I suggest it to be merged as it is.

@bobbylight bobbylight merged commit ef323ee into bobbylight:master Jun 18, 2025
5 checks passed
@bobbylight
Copy link
Copy Markdown
Owner

Thanks for the PR!

@bobbylight bobbylight self-assigned this Jun 18, 2025
@bobbylight bobbylight added this to the 3.4.0 milestone Jun 18, 2025
@OndrejSpanel OndrejSpanel deleted the functions_in_expressions branch June 18, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants