Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix findFunctionName regex sometimes matching if constructs #88

Merged
merged 2 commits into from
Dec 1, 2022

Conversation

ekisu
Copy link
Contributor

@ekisu ekisu commented Nov 18, 2022

Sometimes the findFunctionName function would falsely identify a snippet somewhere around an if/while/catch construct (basically anything that had a block with it)

Description

The regex that matched with the snippet basically attempted to match anything on the form <function name><whitespace>(<parameter list>)<whitespace>{, so things like the following would match:

  • foo(); } else if (b) { (); } else if (b, in this case, would be the parameter list)
  • functionCall()\nif (condition) { (in this case, functionCall()\nif would be the function name)

To work around that, I changed the regex to not matching opening parenthesis, and the regex to not match any closing parenthesis.

Motivation and Context

Fixes #54

How Has This Been Tested?

I've added an unit test, and I've tested this change with some private code that also happened to trigger this bug

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • npm run lint passes without errors
  • npm run test passes without errors
  • I have read the contribution guidelines
  • I have updated the documentation accordingly
  • I have added tests to cover my changes

@eriwen eriwen merged commit 62f6967 into stacktracejs:master Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

_findFunctionName regex bug.
3 participants