bare return statements

This commit is contained in:
Dmitry Vasilev
2024-02-02 03:13:21 +08:00
parent e94eee537e
commit e1f7dd437c
4 changed files with 54 additions and 13 deletions

View File

@@ -487,14 +487,13 @@ export const tests = [
)
}),
test('ASI_restrited', () => {
// Currently we forbid bare return statement, TODO
test('ASI_restricted', () => {
assert_equal(
do_parse(`
return
1
`).ok,
false
true
)
assert_equal(
do_parse(`
@@ -945,6 +944,23 @@ export const tests = [
assert_equal(x.result.version_number, 0)
}),
test('bare return statement', () => {
const code = `
function test() {
return
}
test() /*call*/
`
assert_value_explorer(
test_initial_state(code, code.indexOf('test() /*call*/')),
undefined,
)
assert_value_explorer(
test_initial_state(code, code.indexOf('return')),
undefined,
)
}),
test('array spread not iterable', () => {
assert_code_error(
`[...null]`,