Skip to content

Commit

Permalink
Add restdestructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Apr 10, 2023
1 parent 332db1c commit 7f0aa45
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/lparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3667,19 +3667,7 @@ static void checktoclose (FuncState *fs, int level) {
}


static void destructuring (LexState *ls) {
auto line = ls->getLineNumber();
std::vector<std::pair<TString*, expdesc>> pairs{};
luaX_next(ls); /* skip '{' */
do {
TString* var = str_checkname(ls);
TString* prop = var;
if (testnext(ls, '='))
prop = str_checkname(ls);
expdesc propexp;
codestring(&propexp, prop);
pairs.emplace_back(var, std::move(propexp));
} while (testnext(ls, ','));
static void restdestructuring (LexState *ls, int line, std::vector<std::pair<TString*, expdesc>>& pairs) {
check_match(ls, '}', '{', line);
checknext(ls, '=');

Expand Down Expand Up @@ -3728,6 +3716,22 @@ static void destructuring (LexState *ls) {
}
}

static void destructuring (LexState *ls) {
auto line = ls->getLineNumber();
std::vector<std::pair<TString*, expdesc>> pairs{};
luaX_next(ls); /* skip '{' */
do {
TString* var = str_checkname(ls);
TString* prop = var;
if (testnext(ls, '='))
prop = str_checkname(ls);
expdesc propexp;
codestring(&propexp, prop);
pairs.emplace_back(var, std::move(propexp));
} while (testnext(ls, ','));
restdestructuring(ls, line, pairs);
}


static void localstat (LexState *ls) {
if (ls->t.token == '{') {
Expand Down

0 comments on commit 7f0aa45

Please sign in to comment.