Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Units/parser-javascript.r/js-arrow-funcs.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ f3 input.js /^let f3 = () => {$/;" function signature:()
f4 input.js /^let f4 = (...x) => {$/;" function signature:(...x)
f5 input.js /^let f5 = (x,...y) => {$/;" function signature:(x,...y)
f6 input.js /^let f6 = (x,y,...z) => {$/;" function signature:(x,y,...z)
a input.js /^var a = {}$/;" variable
b input.js /^var b = {}$/;" variable
f7 input.js /^a.f7 = x => {$/;" function variable:a signature:(x)
f8 input.js /^a.f8 = async () => {$/;" function variable:a signature:()
f9 input.js /^b.f9 = (async () => {$/;" function variable:b signature:()
f10 input.js /^b.f10 = (async x => {$/;" function variable:b signature:(x)
a input-0.js /^function a() {$/;" function signature:()
b input-0.js /^ function b() {$/;" function function:a signature:()
c input-0.js /^function c() {$/;" function signature:()
d input-0.js /^ let d = () => {$/;" function function:c signature:()
d2 input-0.js /^ function d2() {$/;" function function:c signature:()
e input-0.js /^let e = () => {$/;" function signature:()
f input-0.js /^ function f() {$/;" function function:e signature:()
g input-0.js /^let g = () => {$/;" function signature:()
h input-0.js /^ let h = () => {$/;" function function:g signature:()
i input-0.js /^ let i = x => {$/;" function function:g signature:(x)
j input-0.js /^ let j = () => {$/;" function function:g signature:()
k input-0.js /^function k() {}$/;" function signature:()
38 changes: 38 additions & 0 deletions Units/parser-javascript.r/js-arrow-funcs.d/input-0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function a() {
function b() {
let x = 42;
return x;
}
let y = b();
return y
}

function c() {
let d = () => {
return 42;
}

function d2() {
return 1;
}
}

let e = () => {
function f() {

}
}

let g = () => {
let h = () => {
return 42;
}
let i = x => {
return x * 42;
}
let j = () => {
return 42;
}
}

function k() {}
15 changes: 15 additions & 0 deletions Units/parser-javascript.r/js-arrow-funcs.d/input.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,58 @@
var f0 = (x) => {
const ignoreme = 1;
console.log('hello');
}

var f1 = (x, y) => {
var ignoreme = 1;
console.log('hello');
}

const f2 = x => {
let ignoreme = 1;
console.log('hello');
}

let f3 = () => {
const ignoreme = 1;
console.log('hello');
}

let f4 = (...x) => {
const ignoreme = 1;
console.log('hello');
}

let f5 = (x,...y) => {
const ignoreme = 1;
console.log('hello');
}

let f6 = (x,y,...z) => {
const ignoreme = 1;
console.log('hello');
}

// Make this input acceptable as the input for nodejs.
var a = {}
var b = {}

a.f7 = x => {
const ignoreme = 1;
console.log('hello');
}

a.f8 = async () => {
const ignoreme = 1;
console.log('hello');
}

b.f9 = (async () => {
const ignoreme = 1;
console.log('hello');
})

b.f10 = (async x => {
const ignoreme = 1;
console.log('hello');
})
15 changes: 15 additions & 0 deletions parsers/jscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,12 @@
state->indexForName = makeFunctionTag (name, sig, false);
else
convertToFunction (state->indexForName, vStringValue (sig));

readToken (token);
if (isType (token, TOKEN_OPEN_CURLY))
parseBlock (token, state->indexForName);
else if (! isType (token, TOKEN_SEMICOLON))
state->isTerminated = false;

Check warning on line 2916 in parsers/jscript.c

View check run for this annotation

Codecov / codecov/patch

parsers/jscript.c#L2915-L2916

Added lines #L2915 - L2916 were not covered by tests
}
vStringDelete (sig);
}
Expand Down Expand Up @@ -2942,6 +2948,15 @@

vStringDelete (sig);
sig = NULL;
readToken (token);
if (isType (token, TOKEN_OPEN_CURLY))
{
parseBlock (token, state->indexForName);
/* here we're at the close curly but it's part of the arrow
* function body, so skip over not to confuse further code */
readTokenFull(token, true, NULL);
state->isTerminated = isType (token, TOKEN_SEMICOLON);
}
}
}
if (isType (token, TOKEN_CLOSE_CURLY))
Expand Down
Loading