Skip to content

Commit

Permalink
Throw unimplemented error when using spread operator (#1926)
Browse files Browse the repository at this point in the history
* Add unimplemented error when using spread (...)

* Error in resolver only with proper ReportMode

* Add name and email to NOTICE

* Change my email in NOTICE

Co-authored-by: romdotdog <romdotdog@users.noreply.github.com>
  • Loading branch information
romdotdog and romdotdog authored Jun 28, 2021
1 parent 5eebd2f commit c441afd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ under the licensing terms detailed in LICENSE:
* bnbarak <bn.barak@gmail.com>
* Colin Eberhardt <colin.eberhardt@gmail.com>
* Ryan Pivovar <ryanpivovar@gmail.com>
* Roman F. <70765447+romdotdog@users.noreply.github.com>
* Joe Pea <trusktr@gmail.com>

Portions of this software are derived from third-party works licensed under
Expand Down
7 changes: 7 additions & 0 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9745,6 +9745,13 @@ export class Compiler extends DiagnosticEmitter {
case Token.TYPEOF: {
return this.compileTypeof(expression, contextualType, constraints);
}
case Token.DOT_DOT_DOT: {
this.error(
DiagnosticCode.Not_implemented_0,
expression.range, "Spread operator"
);
return module.unreachable();
}
default: {
assert(false);
return module.unreachable();
Expand Down
9 changes: 9 additions & 0 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,15 @@ export class Resolver extends DiagnosticEmitter {
}
return type.intType;
}
case Token.DOT_DOT_DOT: {
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Not_implemented_0,
node.range, "Spread operator"
);
}
return null;
}
default: assert(false);
}
return null;
Expand Down

0 comments on commit c441afd

Please sign in to comment.