(kind: string, options)
| 1831 | // https://tc39.github.io/ecma262/#sec-let-and-const-declarations |
| 1832 | |
| 1833 | parseLexicalBinding(kind: string, options): Node.VariableDeclarator { |
| 1834 | const node = this.createNode(); |
| 1835 | const params = []; |
| 1836 | const id = this.parsePattern(params, kind); |
| 1837 | |
| 1838 | if (this.context.strict && id.type === Syntax.Identifier) { |
| 1839 | if (this.scanner.isRestrictedWord((id as Node.Identifier).name)) { |
| 1840 | this.tolerateError(Messages.StrictVarName); |
| 1841 | } |
| 1842 | } |
| 1843 | |
| 1844 | let init: Node.Expression | null = null; |
| 1845 | if (kind === 'const') { |
| 1846 | if (!this.matchKeyword('in') && !this.matchContextualKeyword('of')) { |
| 1847 | if (this.match('=')) { |
| 1848 | this.nextToken(); |
| 1849 | init = this.isolateCoverGrammar(this.parseAssignmentExpression); |
| 1850 | } else { |
| 1851 | this.throwError(Messages.DeclarationMissingInitializer, 'const'); |
| 1852 | } |
| 1853 | } |
| 1854 | } else if ((!options.inFor && id.type !== Syntax.Identifier) || this.match('=')) { |
| 1855 | this.expect('='); |
| 1856 | init = this.isolateCoverGrammar(this.parseAssignmentExpression); |
| 1857 | } |
| 1858 | |
| 1859 | return this.finalize(node, new Node.VariableDeclarator(id, init)); |
| 1860 | } |
| 1861 | |
| 1862 | parseBindingList(kind: string, options): Node.VariableDeclarator[] { |
| 1863 | const list = [this.parseLexicalBinding(kind, options)]; |
no test coverage detected