From d58536e123fe5d5a1ccb489b95edb5842487e035 Mon Sep 17 00:00:00 2001 From: Kenny F Date: Sat, 27 Jul 2019 22:05:39 +0800 Subject: [PATCH] fix(parser): fixed LGTM warnings --- src/parser.ts | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/parser.ts b/src/parser.ts index 25afe054..10ac63ae 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -2213,23 +2213,38 @@ export function parseForStatement( if (parser.token === Token.OfKeyword) report(parser, Errors.ForOfLet); } } else { - // 'var', 'const' - nextToken(parser, context); - const kind = KeywordDescTable[token & Token.Type] as 'var' | 'const'; - - init = finishNode(parser, context, tokenPos, linePos, colPos, { - type: 'VariableDeclaration', - kind, - declarations: parseVariableDeclarationList( - parser, - context | Context.DisallowIn, - scope, - kind === 'var' ? BindingKind.Variable : BindingKind.Const, - BindingOrigin.ForStatement - ) - }); + init = finishNode( + parser, + context, + tokenPos, + linePos, + colPos, + token === Token.VarKeyword + ? { + type: 'VariableDeclaration', + kind: 'var', + declarations: parseVariableDeclarationList( + parser, + context | Context.DisallowIn, + scope, + BindingKind.Variable, + BindingOrigin.ForStatement + ) + } + : { + type: 'VariableDeclaration', + kind: 'const', + declarations: parseVariableDeclarationList( + parser, + context | Context.DisallowIn, + scope, + BindingKind.Const, + BindingOrigin.ForStatement + ) + } + ); parser.assignable = AssignmentKind.Assignable; } @@ -7446,7 +7461,7 @@ export function parseClassDeclaration( nextToken(parser, context); - const { tokenPos, linePos, colPos, tokenValue } = parser; + const { tokenValue } = parser; if ( ((parser.token & 0b0000000000000000001_0000_11111111) ^ 0b0000000000000000000_0000_01010100) >