(type, statement, context)
| 22475 | } |
| 22476 | |
| 22477 | function blockVariableStatement(type, statement, context) { |
| 22478 | // used for both let and const statements |
| 22479 | |
| 22480 | var prefix = context && context.prefix; |
| 22481 | var inexport = context && context.inexport; |
| 22482 | var isLet = type === "let"; |
| 22483 | var isConst = type === "const"; |
| 22484 | var tokens, lone, value, letblock; |
| 22485 | |
| 22486 | if (!state.inES6()) { |
| 22487 | warning("W104", state.tokens.curr, type, "6"); |
| 22488 | } |
| 22489 | |
| 22490 | if (isLet && state.tokens.next.value === "(") { |
| 22491 | if (!state.inMoz()) { |
| 22492 | warning("W118", state.tokens.next, "let block"); |
| 22493 | } |
| 22494 | advance("("); |
| 22495 | state.funct["(scope)"].stack(); |
| 22496 | letblock = true; |
| 22497 | } else if (state.funct["(noblockscopedvar)"]) { |
| 22498 | error("E048", state.tokens.curr, isConst ? "Const" : "Let"); |
| 22499 | } |
| 22500 | |
| 22501 | statement.first = []; |
| 22502 | for (;;) { |
| 22503 | var names = []; |
| 22504 | if (_.contains(["{", "["], state.tokens.next.value)) { |
| 22505 | tokens = destructuringPattern(); |
| 22506 | lone = false; |
| 22507 | } else { |
| 22508 | tokens = [ { id: identifier(), token: state.tokens.curr } ]; |
| 22509 | lone = true; |
| 22510 | } |
| 22511 | |
| 22512 | if (!prefix && isConst && state.tokens.next.id !== "=") { |
| 22513 | warning("E012", state.tokens.curr, state.tokens.curr.value); |
| 22514 | } |
| 22515 | |
| 22516 | for (var t in tokens) { |
| 22517 | if (tokens.hasOwnProperty(t)) { |
| 22518 | t = tokens[t]; |
| 22519 | if (state.funct["(scope)"].block.isGlobal()) { |
| 22520 | if (predefined[t.id] === false) { |
| 22521 | warning("W079", t.token, t.id); |
| 22522 | } |
| 22523 | } |
| 22524 | if (t.id && !state.funct["(noblockscopedvar)"]) { |
| 22525 | state.funct["(scope)"].addlabel(t.id, { |
| 22526 | type: type, |
| 22527 | token: t.token }); |
| 22528 | names.push(t.token); |
| 22529 | } |
| 22530 | } |
| 22531 | } |
| 22532 | |
| 22533 | if (state.tokens.next.id === "=") { |
| 22534 | advance("="); |
no test coverage detected