Fix some cases of invalid labeled declarations

This commit is contained in:
Brian Ng
2017-08-24 19:00:52 -05:00
parent 5d83e2692f
commit 5e60ad6688
18 changed files with 274 additions and 36 deletions

View File

@@ -0,0 +1 @@
foo: class X {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Invalid labeled declaration (1:5)"
}

View File

@@ -0,0 +1 @@
foo: const bar = null;

View File

@@ -0,0 +1,3 @@
{
"throws": "Invalid labeled declaration (1:5)"
}

View File

@@ -0,0 +1 @@
foo: async function bar() {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Invalid labeled declaration (1:5)"
}

View File

@@ -0,0 +1 @@
foo: function* bar() {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Invalid labeled declaration (1:5)"
}

View File

@@ -0,0 +1 @@
function foo() {"use strict"; bar: function baz() {}}

View File

@@ -0,0 +1,3 @@
{
"throws": "Invalid labeled declaration (1:35)"
}

View File

@@ -0,0 +1 @@
foo: let bar;

View File

@@ -0,0 +1,3 @@
{
"throws": "Invalid labeled declaration (1:5)"
}

View File

@@ -0,0 +1 @@
foo: function bar() {}

View File

@@ -0,0 +1,119 @@
{
"type": "File",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 22
}
},
"program": {
"type": "Program",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 22
}
},
"sourceType": "script",
"body": [
{
"type": "LabeledStatement",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 22
}
},
"body": {
"type": "FunctionDeclaration",
"start": 5,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "bar"
},
"name": "bar"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 22
}
},
"body": [],
"directives": []
}
},
"label": {
"type": "Identifier",
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
},
"identifierName": "foo"
},
"name": "foo"
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1 @@
foo: var bar;

View File

@@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"sourceType": "script",
"body": [
{
"type": "LabeledStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"body": {
"type": "VariableDeclaration",
"start": 5,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 13
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "bar"
},
"name": "bar"
},
"init": null
}
],
"kind": "var"
},
"label": {
"type": "Identifier",
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
},
"identifierName": "foo"
},
"name": "foo"
}
}
],
"directives": []
}
}