Skip to content

Fix crash when serializing the return type of a generic call to Array.prototype.flat - #38904

Merged
Wesley Wigham (weswigham) merged 4 commits into
microsoft:masterfrom
weswigham:fix-arrayflat-crash
Jun 15, 2020
Merged

Fix crash when serializing the return type of a generic call to Array.prototype.flat#38904
Wesley Wigham (weswigham) merged 4 commits into
microsoft:masterfrom
weswigham:fix-arrayflat-crash

Conversation

@weswigham

Copy link
Copy Markdown
Member

Fixes#38298

This fix is two-pronged:

  • First, node serialization now has a guard during conditional type serialization that issues an error if it attempts to serialize a union within itself (and therefore will repeat endlessly).
  • Second, to reduce the likelihood of such a scenario occurring in the first place, we now preserve alias symbols on generic indexed accesses, and on the resulting unions or intersections instantiating those indexed accesses may produce. This creates a number of improvements to our .types and error message baselines where many complex types got reduced to SomeAlias<T> or the like. That should be an improvement for many situations outside of the crashing one.

@weswigham

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 2, 2020

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the parallelized community code test suite on this PR at 6658f1e. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 2, 2020

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the parallelized Definitely Typed test suite on this PR at 6658f1e. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 2, 2020

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the extended test suite on this PR at 6658f1e. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 2, 2020

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the perf test suite on this PR at 6658f1e. You can monitor the build here.

Update: The results are in!

@typescript-bot

Copy link
Copy Markdown
Contributor

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@typescript-bot

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..38904

Metricmaster38904DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used328,367k (± 0.03%)327,951k (± 0.02%)-416k (- 0.13%)327,773k328,079k
Parse Time1.65s (± 0.30%)1.65s (± 0.71%)+0.01s (+ 0.36%)1.62s1.67s
Bind Time0.90s (± 0.81%)0.91s (± 1.09%)+0.01s (+ 0.67%)0.88s0.93s
Check Time4.86s (± 0.33%)4.87s (± 0.36%)+0.01s (+ 0.23%)4.83s4.90s
Emit Time5.43s (± 0.60%)5.40s (± 0.45%)-0.03s (- 0.59%)5.33s5.45s
Total Time12.84s (± 0.35%)12.83s (± 0.37%)-0.01s (- 0.06%)12.72s12.91s
Monaco - node (v10.16.3, x64)
Memory used327,355k (± 0.02%)327,389k (± 0.02%)+34k (+ 0.01%)327,269k327,516k
Parse Time1.27s (± 0.65%)1.28s (± 0.73%)+0.01s (+ 0.71%)1.26s1.30s
Bind Time0.79s (± 0.66%)0.79s (± 0.70%)+0.00s (+ 0.38%)0.78s0.80s
Check Time4.88s (± 0.54%)4.91s (± 0.60%)+0.04s (+ 0.72%)4.86s4.99s
Emit Time2.95s (± 0.68%)2.97s (± 1.29%)+0.02s (+ 0.81%)2.89s3.08s
Total Time9.89s (± 0.43%)9.96s (± 0.61%)+0.07s (+ 0.73%)9.86s10.09s
TFS - node (v10.16.3, x64)
Memory used292,454k (± 0.02%)292,477k (± 0.01%)+22k (+ 0.01%)292,406k292,542k
Parse Time0.96s (± 0.62%)0.97s (± 0.62%)+0.00s (+ 0.00%)0.95s0.98s
Bind Time0.76s (± 0.39%)0.76s (± 0.85%)+0.00s (+ 0.53%)0.75s0.78s
Check Time4.40s (± 0.58%)4.42s (± 0.46%)+0.01s (+ 0.32%)4.37s4.46s
Emit Time3.10s (± 0.50%)3.08s (± 0.85%)-0.02s (- 0.58%)3.00s3.12s
Total Time9.23s (± 0.34%)9.23s (± 0.36%)+0.00s (+ 0.03%)9.12s9.29s
material-ui - node (v10.16.3, x64)
Memory used449,999k (± 0.01%)449,729k (± 0.01%)-270k (- 0.06%)449,578k449,905k
Parse Time1.79s (± 0.34%)1.79s (± 0.37%)+0.00s (+ 0.22%)1.78s1.81s
Bind Time0.70s (± 0.57%)0.70s (± 0.63%)+0.00s (+ 0.14%)0.69s0.71s
Check Time12.91s (± 0.97%)12.94s (± 1.10%)+0.03s (+ 0.19%)12.73s13.23s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.40s (± 0.80%)15.43s (± 0.94%)+0.03s (+ 0.19%)15.23s15.74s
Angular - node (v12.1.0, x64)
Memory used303,913k (± 0.03%)303,470k (± 0.03%)-443k (- 0.15%)303,281k303,652k
Parse Time1.60s (± 0.62%)1.60s (± 0.86%)+0.01s (+ 0.38%)1.57s1.63s
Bind Time0.88s (± 0.41%)0.89s (± 1.01%)+0.00s (+ 0.23%)0.86s0.90s
Check Time4.73s (± 0.70%)4.73s (± 0.52%)-0.01s (- 0.13%)4.69s4.78s
Emit Time5.56s (± 1.03%)5.56s (± 0.59%)-0.01s (- 0.11%)5.50s5.65s
Total Time12.78s (± 0.61%)12.78s (± 0.43%)-0.01s (- 0.04%)12.69s12.88s
Monaco - node (v12.1.0, x64)
Memory used307,272k (± 0.01%)307,323k (± 0.02%)+52k (+ 0.02%)307,156k307,433k
Parse Time1.23s (± 0.71%)1.22s (± 0.49%)-0.00s (- 0.33%)1.21s1.24s
Bind Time0.76s (± 1.05%)0.76s (± 0.79%)-0.01s (- 0.79%)0.74s0.77s
Check Time4.69s (± 0.44%)4.71s (± 0.63%)+0.01s (+ 0.32%)4.64s4.78s
Emit Time2.99s (± 0.96%)3.00s (± 0.94%)+0.01s (+ 0.30%)2.95s3.08s
Total Time9.68s (± 0.45%)9.69s (± 0.59%)+0.01s (+ 0.13%)9.55s9.82s
TFS - node (v12.1.0, x64)
Memory used274,696k (± 0.02%)274,779k (± 0.01%)+83k (+ 0.03%)274,696k274,822k
Parse Time0.93s (± 0.60%)0.94s (± 0.79%)+0.01s (+ 0.86%)0.92s0.95s
Bind Time0.74s (± 0.90%)0.74s (± 2.50%)-0.00s (- 0.27%)0.72s0.81s
Check Time4.30s (± 0.41%)4.32s (± 0.46%)+0.02s (+ 0.54%)4.27s4.38s
Emit Time3.10s (± 1.08%)3.11s (± 0.82%)+0.01s (+ 0.29%)3.04s3.15s
Total Time9.07s (± 0.52%)9.11s (± 0.49%)+0.04s (+ 0.46%)9.03s9.23s
material-ui - node (v12.1.0, x64)
Memory used427,320k (± 0.05%)427,075k (± 0.05%)-245k (- 0.06%)426,279k427,447k
Parse Time1.76s (± 0.43%)1.77s (± 0.81%)+0.01s (+ 0.34%)1.74s1.80s
Bind Time0.64s (± 1.06%)0.65s (± 0.51%)+0.01s (+ 0.93%)0.64s0.66s
Check Time11.44s (± 0.84%)11.48s (± 0.62%)+0.04s (+ 0.38%)11.33s11.64s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time13.84s (± 0.67%)13.90s (± 0.55%)+0.06s (+ 0.40%)13.73s14.08s
Angular - node (v8.9.0, x64)
Memory used323,207k (± 0.02%)322,856k (± 0.02%)-351k (- 0.11%)322,672k323,051k
Parse Time2.12s (± 0.46%)2.13s (± 0.63%)+0.01s (+ 0.38%)2.10s2.16s
Bind Time0.94s (± 0.96%)0.94s (± 1.22%)-0.00s (- 0.32%)0.93s0.98s
Check Time5.53s (± 1.02%)5.46s (± 1.64%)-0.08s (- 1.41%)5.29s5.63s
Emit Time6.31s (± 1.14%)6.35s (± 0.99%)+0.05s (+ 0.76%)6.27s6.55s
Total Time14.90s (± 0.40%)14.88s (± 0.50%)-0.03s (- 0.17%)14.69s15.05s
Monaco - node (v8.9.0, x64)
Memory used325,943k (± 0.01%)326,019k (± 0.01%)+76k (+ 0.02%)325,949k326,075k
Parse Time1.56s (± 0.49%)1.56s (± 0.68%)+0.01s (+ 0.51%)1.55s1.59s
Bind Time0.92s (± 1.35%)0.92s (± 1.31%)-0.01s (- 0.65%)0.90s0.96s
Check Time5.49s (± 0.70%)5.49s (± 0.62%)+0.00s (+ 0.09%)5.40s5.57s
Emit Time3.50s (± 0.65%)3.47s (± 0.70%)-0.03s (- 0.83%)3.40s3.52s
Total Time11.47s (± 0.47%)11.44s (± 0.45%)-0.03s (- 0.23%)11.33s11.56s
TFS - node (v8.9.0, x64)
Memory used292,052k (± 0.02%)292,101k (± 0.01%)+49k (+ 0.02%)292,024k292,197k
Parse Time1.26s (± 0.67%)1.25s (± 0.47%)-0.01s (- 0.56%)1.24s1.27s
Bind Time0.75s (± 0.79%)0.76s (± 1.18%)+0.00s (+ 0.27%)0.74s0.78s
Check Time5.01s (± 1.60%)5.12s (± 1.39%)+0.11s (+ 2.14%)4.93s5.21s
Emit Time3.28s (± 2.49%)3.20s (± 2.39%)-0.08s (- 2.41%)3.12s3.40s
Total Time10.30s (± 0.50%)10.33s (± 0.41%)+0.03s (+ 0.27%)10.27s10.43s
material-ui - node (v8.9.0, x64)
Memory used452,949k (± 0.01%)452,700k (± 0.02%)-248k (- 0.05%)452,475k452,918k
Parse Time2.12s (± 0.50%)2.12s (± 0.46%)-0.00s (- 0.09%)2.11s2.15s
Bind Time0.82s (± 0.81%)0.82s (± 1.24%)+0.00s (+ 0.12%)0.80s0.85s
Check Time16.86s (± 1.01%)16.85s (± 0.53%)-0.00s (- 0.02%)16.60s17.02s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time19.80s (± 0.86%)19.79s (± 0.44%)-0.01s (- 0.04%)19.58s19.96s
Angular - node (v8.9.0, x86)
Memory used186,241k (± 0.02%)186,064k (± 0.03%)-177k (- 0.10%)185,962k186,185k
Parse Time2.06s (± 0.67%)2.07s (± 0.45%)+0.01s (+ 0.39%)2.06s2.10s
Bind Time1.09s (± 1.12%)1.09s (± 0.77%)+0.00s (+ 0.18%)1.08s1.11s
Check Time5.06s (± 0.58%)5.07s (± 0.40%)+0.01s (+ 0.30%)5.02s5.12s
Emit Time6.07s (± 0.68%)6.08s (± 0.84%)+0.01s (+ 0.15%)5.92s6.16s
Total Time14.28s (± 0.49%)14.32s (± 0.39%)+0.03s (+ 0.24%)14.18s14.41s
Monaco - node (v8.9.0, x86)
Memory used185,806k (± 0.02%)185,787k (± 0.02%)-19k (- 0.01%)185,715k185,892k
Parse Time1.60s (± 0.64%)1.60s (± 0.47%)-0.00s (- 0.13%)1.58s1.62s
Bind Time0.77s (± 0.75%)0.77s (± 0.52%)-0.00s (- 0.26%)0.76s0.78s
Check Time5.48s (± 0.39%)5.51s (± 0.47%)+0.04s (+ 0.64%)5.46s5.59s
Emit Time2.90s (± 0.68%)2.89s (± 0.79%)-0.00s (- 0.14%)2.84s2.95s
Total Time10.75s (± 0.36%)10.78s (± 0.22%)+0.03s (+ 0.26%)10.72s10.83s
TFS - node (v8.9.0, x86)
Memory used167,389k (± 0.02%)167,390k (± 0.02%)+2k (+ 0.00%)167,318k167,455k
Parse Time1.29s (± 0.68%)1.29s (± 0.45%)0.00s ( 0.00%)1.28s1.30s
Bind Time0.72s (± 1.11%)0.72s (± 0.72%)-0.00s (- 0.14%)0.71s0.73s
Check Time4.71s (± 0.59%)4.72s (± 0.77%)+0.02s (+ 0.32%)4.65s4.82s
Emit Time2.98s (± 0.78%)2.99s (± 2.62%)+0.01s (+ 0.34%)2.89s3.25s
Total Time9.70s (± 0.40%)9.72s (± 0.85%)+0.02s (+ 0.24%)9.60s9.98s
material-ui - node (v8.9.0, x86)
Memory used256,662k (± 0.01%)256,526k (± 0.02%)-135k (- 0.05%)256,422k256,628k
Parse Time2.18s (± 0.58%)2.18s (± 0.60%)0.00s ( 0.00%)2.16s2.21s
Bind Time0.70s (± 1.63%)0.70s (± 1.58%)+0.01s (+ 0.86%)0.68s0.74s
Check Time15.55s (± 0.89%)15.52s (± 0.74%)-0.03s (- 0.19%)15.24s15.80s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time18.43s (± 0.76%)18.41s (± 0.64%)-0.02s (- 0.12%)18.11s18.67s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
BenchmarkNameIterations
Current3890410
Baselinemaster10

@weswigham

Copy link
Copy Markdown
MemberAuthor

RWC and user all look good. Perf is fine. DT needs some text changes to webpack-config-utils, but otherwise is unaffected. Everything looks good. Ryan Cavanaugh (@RyanCavanaugh) since this was a crash bug, did we want to backport this for the next servicing release?

Comment threadsrc/compiler/checker.ts Outdated
Comment threadsrc/compiler/checker.ts Outdated
Comment threadsrc/compiler/checker.ts
Comment threadsrc/compiler/checker.ts
@weswigham
Wesley Wigham (weswigham) merged commit 6a777ff into microsoft:masterJun 15, 2020
@weswigham

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) cherry-pick this to release-3.9

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 15, 2020

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the task to cherry-pick this into release-3.9 on this PR at e6ccbbd. You can monitor the build here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Wesley Wigham (@weswigham), I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-3.9 manually.

Wesley Wigham (weswigham) added a commit to weswigham/TypeScript that referenced this pull request Jun 15, 2020
….prototype.flat (microsoft#38904)
* Add declaration emit error and checking for circularly referential unions produced by recursive conditionals
* Allow indexed accesses to produce alias symbols on types
* Add test that still triggers the declaration emit error
* Fix spelling
Wesley Wigham (weswigham) added a commit that referenced this pull request Jun 15, 2020
….prototype.flat (#38904) (#39079)
* Add declaration emit error and checking for circularly referential unions produced by recursive conditionals
* Allow indexed accesses to produce alias symbols on types
* Add test that still triggers the declaration emit error
* Fix spelling
Andrew Casey (amcasey) added a commit to amcasey/TypeScript that referenced this pull request Jul 7, 2020
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RangeError when trying to infer type for Array.prototype.flat()

4 participants

@weswigham@typescript-bot@andrewbranch@RyanCavanaugh