-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Compiling of single file with 600 lines takes more than 30 minutes #18158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Simplified repro: function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) {
let r = [];
let v;
r[0] = (v = a0*a0) & 0xFFFF;
r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF;
r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF;
r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF;
r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF;
r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF;
r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF;
r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF;
r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF;
r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF;
r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF;
r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF;
r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF;
// r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF;
// r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF;
// r[15] = ((v / 0x10000) | 0);
return r;
} This takes 10 seconds to parse and gets even worse if more lines are uncommented. Looks like the parser is getting into an expensive series of compounding lookaheads to determine if an expression is an arrow function. |
May be a dupe of #18123. I suspect the addition of jsdoc function type syntax made it harder to tell that something isn't an arrow function, because types are now allowed to start parameters -- jsdoc doesn't include the parameter name. |
Actually, this isn't a dupe of #18123, and it has been around since at least 1.6. I'll see if I can go back to the release that introduced it, but I am not sure I'll be able to build when I get to old enough versions of Typescript. |
Here's the bad commit: 886feda (from 2014!) In scanner.ts, it changes In fact, changing the Changing the |
The reason that changing to I'll send out a PR with the fix and the repro in case we just want to fix the bug quickly, but it would be better to come up with a smarter solution. |
One fix is up at #18294. It's not a great one and could be improved by better detecting when |
#18417 is a better fix than this that works by requiring speculatively parsed arrow functions to have an |
TypeScript Version: 2.4.2
Code
File
curve25519.ts
Running
Expected behavior:
Compling should take few seconds.
Actual behavior:
Compiling takes 30 minutes+ and gives following diagnostics:
The text was updated successfully, but these errors were encountered: