-
-
Notifications
You must be signed in to change notification settings - Fork 75
Fix: Exception thrown when space occurs after function name #124
Conversation
Thanks for the pull request, @soda0289! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing @soda0289!
Please could you address the following before we get this merged:
- See my comment inline for a tweak to the logic
- Add a test in
test/fixtures/ecma-features/classes
and use your example class from TypeError: Cannot read property 'value' of undefined - When parsing with rule space-before-function-paren #123 as the src - Remove the
.swp
file from the commit
@@ -1048,6 +1048,7 @@ module.exports = function(ast, extra) { | |||
case SyntaxKind.GetAccessor: | |||
case SyntaxKind.SetAccessor: | |||
case SyntaxKind.MethodDeclaration: | |||
var offset = node.parameters.pos - node.name.end - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This calculation ends up containing both +node.name.end
and -node.name.end
so we could simplify the range start to just be node.parameters.pos - 1
, and scrap this variable altogether right?
As an aside, most of the conversion currently happens within one single function scope right now, so please give try and give variables more specific and unique names. I will be refactoring at some point once the project has fully stabilised, but just something to bear in mind at the moment.
c204b8d
to
ff9d21a
Compare
Thanks for the pull request, @soda0289! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
ff9d21a
to
415299f
Compare
Thanks for the pull request, @soda0289! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
@JamesHenry |
It's in! Please rebase the PR and we'll see where we're at 😄 |
415299f
to
9eb8f5f
Compare
Thanks for the pull request, @soda0289! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
9eb8f5f
to
82ed70c
Compare
Thanks for the pull request, @soda0289! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
@JamesHenry Let me know if you want anything else changed. |
It is validating against our contributing guidelines. Relevant excerpt:
Well, this change is currently breaking a lot of existing tests (causing the build to fail), so the next job will be to look into those and double-check whether or not that should be the case, i.e. do the tests need updating, or does the code change? Regardless, the PR will only be merged once we get to a point where the build is passing. |
I see the test are failing because some of the positions are off in range array. Will look at this in a couple hours. Thanks. |
…lint#123) We can calculate where the function parameters starts by using node.parameters.pos and adding one.
82ed70c
to
a8501eb
Compare
LGTM |
@JamesHenry |
Can you ensure that the range values are correct for the test I wrote and the one I changed? |
LGTM, thanks! |
Possible fix for #123
When parsing typescript node we need to add an offset when there is a space between function name and parameters.
Still need to add tests. Would like to know if I'm on the right track.