Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Function call recognized as method definition #223

Closed
pchaigno opened this issue Sep 9, 2015 · 5 comments · Fixed by #312
Closed

Function call recognized as method definition #223

pchaigno opened this issue Sep 9, 2015 · 5 comments · Fixed by #312
Labels

Comments

@pchaigno
Copy link
Contributor

pchaigno commented Sep 9, 2015

This function call is recognized as a method definition:

write("){");

It even is in the tests since f579460 (the scopes shouldn't contain meta.method.js).
@50Wliu Is it a mistake or was it placed here as a bug to fix?

This is happening since #134 which added support for this kind of method definitions:

var foo = {
  baz() {}
};

I'm working on a fix. It will required to recognize JavaScript objects ({}) which requires to improve the current support for function and method definitions (to not mistake a function body for an object definition). Actually, that won't fix it and I found an other way :-)

EDIT: That probably should be a wontfix: I don't see how we can distinguish a function call from a method definition inside an object when there is "){" in argument.

@Victorystick
Copy link
Contributor

I see what you mean. Yes, that seems pretty tough. I guess giving strings priority over method declarations doesn't work?

@pchaigno
Copy link
Contributor Author

pchaigno commented Sep 9, 2015

I guess giving strings priority over method declarations doesn't work?

Nop, we don't know yet that there will be a string when we need to decide between function call and method definition :/

@winstliu
Copy link
Contributor

winstliu commented Sep 9, 2015

Well, before it was being tokenized as

(taken from #175)

@winstliu winstliu added the bug label Sep 9, 2015
@pchaigno
Copy link
Contributor Author

pchaigno commented Sep 9, 2015

😄
I guess it's a lot better now.

@Victorystick
Copy link
Contributor

What about this? A helper function called constructor is called on a function, causing highlighting to break for function. Is this related?

// breaks
window.Library = constructor(function Class(object) {
  ...
});

// works
window.Library = constructo(function Class(object) {

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants