Skip to content

[WIP] Update parser and diagnostics for numbers starting with zero - #39698

Closed
Andrii Dieiev (IllusionMH) wants to merge 1 commit into
microsoft:mainfrom
IllusionMH:zero-leading-numbers-39563
Closed

[WIP] Update parser and diagnostics for numbers starting with zero#39698
Andrii Dieiev (IllusionMH) wants to merge 1 commit into
microsoft:mainfrom
IllusionMH:zero-leading-numbers-39563

Conversation

@IllusionMH

@IllusionMHAndrii Dieiev (IllusionMH) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Fixes#39563
Fixes other problems with numbers that start with 0

After couple attempts to improve over scanOctalDigits to handle numeric separators it looked easier to rework parser logic for all numbers that start with 0.

Updated logic is applied only to cases that were previously handled with potential problems: numbers that has leading zero and more than one digit or has numeric separator right after leading zero.

Updated behavior (also see screenshots below):
007 - parsed as octal literal, reported as octal literal in strict mode (as before)
009 - parsed as single numeric literal, reported as zero-leading in strict mode
077_77 - parsed as single numeric literal (not octal), separator reported as not allowed, and reported as zero-leading in strict mode.
0123n - parsed as single BigInt literal (not octal), reported as invalid BigInt literal.
0123identifier - parsed as octal literal (as before), but now reports identifier that immediately follows numeric literal.

I will add updated test later this week.

Daniel Rosenwasser (@DanielRosenwasser) could you run extended test suite on this PR please? I think it worth to see if it's feasible to continue with expanded scope of this PR and what errors worth to add to tests.

Screenshots with new behavior

Before:
image

After:
image

@typescript-botTypeScript Bot (typescript-bot) added the For Backlog Bug PRs that fix a backlog bug label Jul 22, 2020
@DanielRosenwasser

Copy link
Copy Markdown
Member

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the tarball bundle task on this PR at 0d37497. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the perf test suite on this PR at 0d37497. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the extended test suite on this PR at 0d37497. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the parallelized Definitely Typed test suite on this PR at 0d37497. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the parallelized community code test suite on this PR at 0d37497. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Hey Daniel Rosenwasser (@DanielRosenwasser), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/80401/artifacts?artifactName=tgz&fileId=380A418ACCF281F9E9E807427CEE0C9C5EAF8793D9FD48E72A6E50111BF75C9A02&fileName=/typescript-4.0.0-insiders.20200722.tgz"
}
}

and then running npm install.


There is also a playground for this build.

@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

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..39698

Metricmaster39698DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used343,552k (± 0.02%)343,087k (± 0.02%)-465k (- 0.14%)342,984k343,281k
Parse Time2.01s (± 0.60%)2.01s (± 0.53%)+0.00s (+ 0.05%)1.99s2.04s
Bind Time0.82s (± 0.61%)0.82s (± 1.18%)+0.01s (+ 0.74%)0.80s0.84s
Check Time4.74s (± 0.62%)4.77s (± 0.38%)+0.02s (+ 0.48%)4.73s4.81s
Emit Time5.19s (± 1.50%)5.18s (± 0.56%)-0.01s (- 0.27%)5.12s5.24s
Total Time12.76s (± 0.79%)12.78s (± 0.39%)+0.02s (+ 0.14%)12.70s12.90s
Monaco - node (v10.16.3, x64)
Memory used338,974k (± 0.02%)338,978k (± 0.02%)+5k (+ 0.00%)338,831k339,092k
Parse Time1.58s (± 0.89%)1.58s (± 0.55%)-0.01s (- 0.38%)1.56s1.60s
Bind Time0.72s (± 0.51%)0.71s (± 0.51%)-0.00s (- 0.28%)0.71s0.72s
Check Time4.94s (± 0.78%)4.92s (± 0.71%)-0.03s (- 0.51%)4.85s4.99s
Emit Time2.76s (± 0.61%)2.76s (± 0.66%)+0.00s (+ 0.07%)2.72s2.81s
Total Time10.00s (± 0.54%)9.97s (± 0.51%)-0.03s (- 0.31%)9.87s10.06s
TFS - node (v10.16.3, x64)
Memory used301,995k (± 0.03%)301,884k (± 0.02%)-112k (- 0.04%)301,736k302,007k
Parse Time1.21s (± 0.37%)1.21s (± 0.80%)-0.00s (- 0.25%)1.19s1.24s
Bind Time0.67s (± 0.83%)0.67s (± 0.87%)-0.00s (- 0.74%)0.65s0.68s
Check Time4.45s (± 0.60%)4.41s (± 0.63%)-0.04s (- 0.90%)4.37s4.50s
Emit Time2.89s (± 1.13%)2.91s (± 1.27%)+0.02s (+ 0.62%)2.83s2.98s
Total Time9.22s (± 0.58%)9.19s (± 0.66%)-0.03s (- 0.35%)9.08s9.36s
material-ui - node (v10.16.3, x64)
Memory used459,087k (± 0.01%)458,792k (± 0.01%)-295k (- 0.06%)458,678k458,915k
Parse Time2.06s (± 0.67%)2.05s (± 0.50%)-0.01s (- 0.24%)2.02s2.07s
Bind Time0.65s (± 0.95%)0.66s (± 1.62%)+0.00s (+ 0.61%)0.63s0.67s
Check Time12.96s (± 0.96%)12.92s (± 0.78%)-0.04s (- 0.33%)12.76s13.18s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.67s (± 0.82%)15.62s (± 0.72%)-0.04s (- 0.27%)15.43s15.91s
Angular - node (v12.1.0, x64)
Memory used320,807k (± 0.03%)320,377k (± 0.03%)-430k (- 0.13%)320,218k320,565k
Parse Time1.99s (± 0.67%)2.00s (± 0.55%)+0.01s (+ 0.50%)1.97s2.02s
Bind Time0.80s (± 0.87%)0.81s (± 0.64%)+0.01s (+ 1.00%)0.80s0.82s
Check Time4.66s (± 0.63%)4.64s (± 0.44%)-0.02s (- 0.41%)4.60s4.69s
Emit Time5.35s (± 0.53%)5.33s (± 0.68%)-0.01s (- 0.21%)5.28s5.44s
Total Time12.80s (± 0.43%)12.78s (± 0.40%)-0.01s (- 0.10%)12.68s12.89s
Monaco - node (v12.1.0, x64)
Memory used321,500k (± 0.02%)321,470k (± 0.01%)-30k (- 0.01%)321,372k321,570k
Parse Time1.56s (± 0.74%)1.55s (± 0.61%)-0.01s (- 0.83%)1.53s1.57s
Bind Time0.69s (± 0.65%)0.69s (± 0.50%)-0.00s (- 0.15%)0.68s0.69s
Check Time4.72s (± 0.71%)4.70s (± 0.33%)-0.01s (- 0.30%)4.67s4.73s
Emit Time2.80s (± 0.46%)2.81s (± 0.85%)+0.01s (+ 0.36%)2.78s2.89s
Total Time9.77s (± 0.47%)9.75s (± 0.38%)-0.02s (- 0.16%)9.70s9.87s
TFS - node (v12.1.0, x64)
Memory used286,527k (± 0.02%)286,481k (± 0.01%)-46k (- 0.02%)286,367k286,538k
Parse Time1.24s (± 0.36%)1.24s (± 0.73%)-0.00s (- 0.24%)1.22s1.26s
Bind Time0.64s (± 0.87%)0.64s (± 1.05%)-0.00s (- 0.16%)0.62s0.65s
Check Time4.33s (± 0.61%)4.33s (± 0.44%)-0.00s (- 0.12%)4.29s4.38s
Emit Time2.94s (± 0.64%)2.93s (± 0.61%)-0.01s (- 0.44%)2.90s2.97s
Total Time9.16s (± 0.46%)9.14s (± 0.32%)-0.02s (- 0.22%)9.05s9.21s
material-ui - node (v12.1.0, x64)
Memory used437,422k (± 0.05%)437,092k (± 0.05%)-330k (- 0.08%)436,257k437,281k
Parse Time2.04s (± 0.71%)2.03s (± 0.58%)-0.01s (- 0.25%)2.00s2.05s
Bind Time0.63s (± 0.71%)0.63s (± 1.16%)-0.00s (- 0.63%)0.62s0.65s
Check Time11.71s (± 0.84%)11.69s (± 1.23%)-0.01s (- 0.12%)11.48s12.02s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time14.38s (± 0.71%)14.35s (± 1.04%)-0.03s (- 0.20%)14.12s14.69s
Angular - node (v8.9.0, x64)
Memory used340,104k (± 0.01%)339,755k (± 0.02%)-349k (- 0.10%)339,646k339,899k
Parse Time2.54s (± 0.47%)2.54s (± 0.39%)0.00s ( 0.00%)2.52s2.57s
Bind Time0.85s (± 0.61%)0.84s (± 0.62%)-0.01s (- 0.94%)0.83s0.85s
Check Time5.40s (± 0.56%)5.37s (± 0.45%)-0.03s (- 0.54%)5.32s5.44s
Emit Time5.90s (± 1.41%)5.90s (± 2.06%)+0.00s (+ 0.00%)5.65s6.24s
Total Time14.69s (± 0.54%)14.65s (± 0.87%)-0.04s (- 0.27%)14.41s15.01s
Monaco - node (v8.9.0, x64)
Memory used340,340k (± 0.02%)340,328k (± 0.01%)-12k (- 0.00%)340,286k340,424k
Parse Time1.87s (± 0.48%)1.88s (± 0.36%)+0.00s (+ 0.16%)1.86s1.89s
Bind Time0.89s (± 0.54%)0.89s (± 0.79%)+0.00s (+ 0.23%)0.88s0.90s
Check Time5.47s (± 0.66%)5.44s (± 0.60%)-0.03s (- 0.55%)5.34s5.50s
Emit Time3.22s (± 0.78%)3.22s (± 0.99%)+0.00s (+ 0.09%)3.17s3.33s
Total Time11.45s (± 0.44%)11.43s (± 0.52%)-0.02s (- 0.18%)11.27s11.55s
TFS - node (v8.9.0, x64)
Memory used303,729k (± 0.01%)303,759k (± 0.02%)+31k (+ 0.01%)303,652k303,862k
Parse Time1.54s (± 0.44%)1.55s (± 0.58%)+0.01s (+ 0.45%)1.53s1.57s
Bind Time0.67s (± 0.71%)0.67s (± 0.99%)-0.00s (- 0.45%)0.66s0.68s
Check Time5.08s (± 1.38%)5.10s (± 1.38%)+0.02s (+ 0.33%)4.93s5.21s
Emit Time3.06s (± 2.93%)2.98s (± 2.64%)-0.08s (- 2.62%)2.87s3.16s
Total Time10.36s (± 0.37%)10.30s (± 0.38%)-0.06s (- 0.60%)10.21s10.36s
material-ui - node (v8.9.0, x64)
Memory used463,313k (± 0.01%)463,037k (± 0.01%)-276k (- 0.06%)462,977k463,149k
Parse Time2.39s (± 0.35%)2.40s (± 0.63%)+0.01s (+ 0.59%)2.38s2.45s
Bind Time0.78s (± 1.38%)0.78s (± 1.08%)+0.00s (+ 0.00%)0.76s0.80s
Check Time17.27s (± 0.81%)17.30s (± 1.16%)+0.03s (+ 0.15%)16.77s17.84s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time20.44s (± 0.71%)20.48s (± 0.99%)+0.04s (+ 0.19%)19.92s21.03s
Angular - node (v8.9.0, x86)
Memory used195,162k (± 0.04%)194,943k (± 0.03%)-219k (- 0.11%)194,813k195,081k
Parse Time2.46s (± 0.60%)2.45s (± 0.49%)-0.01s (- 0.45%)2.42s2.47s
Bind Time0.99s (± 0.81%)0.99s (± 0.59%)-0.00s (- 0.10%)0.98s1.00s
Check Time4.84s (± 0.82%)4.85s (± 0.87%)+0.01s (+ 0.25%)4.78s4.97s
Emit Time5.91s (± 0.58%)5.90s (± 0.53%)-0.01s (- 0.20%)5.84s5.98s
Total Time14.19s (± 0.46%)14.18s (± 0.50%)-0.01s (- 0.06%)14.08s14.39s
Monaco - node (v8.9.0, x86)
Memory used193,450k (± 0.02%)193,449k (± 0.03%)-2k (- 0.00%)193,344k193,573k
Parse Time1.90s (± 0.44%)1.93s (± 0.97%)+0.03s (+ 1.53%)1.90s1.98s
Bind Time0.70s (± 0.57%)0.70s (± 0.57%)0.00s ( 0.00%)0.69s0.71s
Check Time5.52s (± 0.40%)5.52s (± 1.12%)-0.01s (- 0.13%)5.29s5.60s
Emit Time2.66s (± 0.74%)2.72s (± 2.89%)+0.05s (+ 2.07%)2.63s3.02s
Total Time10.79s (± 0.30%)10.86s (± 0.26%)+0.07s (+ 0.69%)10.78s10.91s
TFS - node (v8.9.0, x86)
Memory used173,675k (± 0.02%)173,690k (± 0.03%)+15k (+ 0.01%)173,612k173,783k
Parse Time1.61s (± 1.22%)1.59s (± 0.90%)-0.02s (- 1.06%)1.57s1.63s
Bind Time0.64s (± 0.90%)0.64s (± 0.90%)-0.00s (- 0.47%)0.63s0.66s
Check Time4.68s (± 0.53%)4.67s (± 0.64%)-0.00s (- 0.09%)4.63s4.76s
Emit Time2.79s (± 1.18%)2.76s (± 1.26%)-0.03s (- 1.01%)2.67s2.81s
Total Time9.71s (± 0.60%)9.66s (± 0.54%)-0.05s (- 0.54%)9.54s9.79s
material-ui - node (v8.9.0, x86)
Memory used262,396k (± 0.01%)262,266k (± 0.02%)-130k (- 0.05%)262,150k262,376k
Parse Time2.45s (± 0.64%)2.45s (± 0.91%)+0.00s (+ 0.12%)2.39s2.50s
Bind Time0.67s (± 1.67%)0.67s (± 1.52%)-0.00s (- 0.15%)0.65s0.69s
Check Time15.67s (± 0.66%)15.73s (± 0.75%)+0.06s (+ 0.41%)15.51s16.01s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time18.78s (± 0.61%)18.85s (± 0.70%)+0.07s (+ 0.36%)18.61s19.19s
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
Current3969810
Baselinemaster10

@IllusionMH

Copy link
Copy Markdown
ContributorAuthor

Daniel Rosenwasser (@DanielRosenwasser) thank you!

Looks like there is only one new error specific to this PR and it's correct:

Error in luxon
Error: /home/vsts/work/1/s/dtslint-runner/DefinitelyTyped/types/luxon/luxon-tests.ts:250:43
ERROR: 250:43 expect TypeScript@local compile error: Number literals starting with '0' are not allowed in strict mode.

Reported line: const local = DateTime.local(2017, 5, 15, 09, 10, 23);

@sandersn

Copy link
Copy Markdown
Member

To help with PR housekeeping, I'm going to close this draft PR. It's pretty old.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog BugPRs that fix a backlog bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numeric separated literals should disallow zero leading

4 participants

@IllusionMH@DanielRosenwasser@typescript-bot@sandersn