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

Arrow functions with a single param as default arguments to functions #193

Closed
ghost opened this issue Aug 8, 2015 · 6 comments · Fixed by #312
Closed

Arrow functions with a single param as default arguments to functions #193

ghost opened this issue Aug 8, 2015 · 6 comments · Fixed by #312

Comments

@ghost
Copy link

ghost commented Aug 8, 2015

// incorrect highlighting - arrow isn't highlighted
function f (a = _ => _) { }
function f (a = arg => arg) { }
function f (a = ret => ret) { }
function f (a = pchaigno => pchaigno) { }

// correct highlighting - arrow is highlighted
function f (a = (_) => _) { }
function f (a = (arg) => arg) { }
function f (a = (ret) => ret) { }
function f (a = (pchaigno) => pchaigno) { }
@winstliu winstliu added the bug label Aug 8, 2015
@pchaigno
Copy link
Contributor

@bucaran Is it only _ that is authorized here or could it be function f (a = arg1 => _) { }? Do you know where I could find specifications on this?

@ghost
Copy link
Author

ghost commented Aug 25, 2015

It could be anything, it's just the argument name. I updated the example. @pchaigno

@winstliu
Copy link
Contributor

I looked into this a while ago and found that it was because the arrow regex matcher currently mandates an opening and closing parentheses before it'll match =>. I couldn't get it to work properly without parentheses, but I can try again :).

@pchaigno
Copy link
Contributor

Is this valid too?

function f(a = x, y => x + y) {}

@ghost
Copy link
Author

ghost commented Aug 26, 2015

It's not.

The following is:

function f(a = x, y = () => {}) {

}

@pchaigno
Copy link
Contributor

Ouch! That's going to be a tricky one...

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

Successfully merging a pull request may close this issue.

2 participants