Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Closed

Conversation

IllusionMH
Copy link
Contributor

@IllusionMH IllusionMH commented Jul 22, 2020

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.

@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-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jul 22, 2020
@DanielRosenwasser
Copy link
Member

@typescript-bot pack this
@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

Heya @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
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

Heya @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
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

Heya @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
Copy link
Collaborator

typescript-bot commented Jul 22, 2020

Hey @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
Collaborator

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
Collaborator

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..39698

Metric master 39698 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 343,552k (± 0.02%) 343,087k (± 0.02%) -465k (- 0.14%) 342,984k 343,281k
Parse Time 2.01s (± 0.60%) 2.01s (± 0.53%) +0.00s (+ 0.05%) 1.99s 2.04s
Bind Time 0.82s (± 0.61%) 0.82s (± 1.18%) +0.01s (+ 0.74%) 0.80s 0.84s
Check Time 4.74s (± 0.62%) 4.77s (± 0.38%) +0.02s (+ 0.48%) 4.73s 4.81s
Emit Time 5.19s (± 1.50%) 5.18s (± 0.56%) -0.01s (- 0.27%) 5.12s 5.24s
Total Time 12.76s (± 0.79%) 12.78s (± 0.39%) +0.02s (+ 0.14%) 12.70s 12.90s
Monaco - node (v10.16.3, x64)
Memory used 338,974k (± 0.02%) 338,978k (± 0.02%) +5k (+ 0.00%) 338,831k 339,092k
Parse Time 1.58s (± 0.89%) 1.58s (± 0.55%) -0.01s (- 0.38%) 1.56s 1.60s
Bind Time 0.72s (± 0.51%) 0.71s (± 0.51%) -0.00s (- 0.28%) 0.71s 0.72s
Check Time 4.94s (± 0.78%) 4.92s (± 0.71%) -0.03s (- 0.51%) 4.85s 4.99s
Emit Time 2.76s (± 0.61%) 2.76s (± 0.66%) +0.00s (+ 0.07%) 2.72s 2.81s
Total Time 10.00s (± 0.54%) 9.97s (± 0.51%) -0.03s (- 0.31%) 9.87s 10.06s
TFS - node (v10.16.3, x64)
Memory used 301,995k (± 0.03%) 301,884k (± 0.02%) -112k (- 0.04%) 301,736k 302,007k
Parse Time 1.21s (± 0.37%) 1.21s (± 0.80%) -0.00s (- 0.25%) 1.19s 1.24s
Bind Time 0.67s (± 0.83%) 0.67s (± 0.87%) -0.00s (- 0.74%) 0.65s 0.68s
Check Time 4.45s (± 0.60%) 4.41s (± 0.63%) -0.04s (- 0.90%) 4.37s 4.50s
Emit Time 2.89s (± 1.13%) 2.91s (± 1.27%) +0.02s (+ 0.62%) 2.83s 2.98s
Total Time 9.22s (± 0.58%) 9.19s (± 0.66%) -0.03s (- 0.35%) 9.08s 9.36s
material-ui - node (v10.16.3, x64)
Memory used 459,087k (± 0.01%) 458,792k (± 0.01%) -295k (- 0.06%) 458,678k 458,915k
Parse Time 2.06s (± 0.67%) 2.05s (± 0.50%) -0.01s (- 0.24%) 2.02s 2.07s
Bind Time 0.65s (± 0.95%) 0.66s (± 1.62%) +0.00s (+ 0.61%) 0.63s 0.67s
Check Time 12.96s (± 0.96%) 12.92s (± 0.78%) -0.04s (- 0.33%) 12.76s 13.18s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.67s (± 0.82%) 15.62s (± 0.72%) -0.04s (- 0.27%) 15.43s 15.91s
Angular - node (v12.1.0, x64)
Memory used 320,807k (± 0.03%) 320,377k (± 0.03%) -430k (- 0.13%) 320,218k 320,565k
Parse Time 1.99s (± 0.67%) 2.00s (± 0.55%) +0.01s (+ 0.50%) 1.97s 2.02s
Bind Time 0.80s (± 0.87%) 0.81s (± 0.64%) +0.01s (+ 1.00%) 0.80s 0.82s
Check Time 4.66s (± 0.63%) 4.64s (± 0.44%) -0.02s (- 0.41%) 4.60s 4.69s
Emit Time 5.35s (± 0.53%) 5.33s (± 0.68%) -0.01s (- 0.21%) 5.28s 5.44s
Total Time 12.80s (± 0.43%) 12.78s (± 0.40%) -0.01s (- 0.10%) 12.68s 12.89s
Monaco - node (v12.1.0, x64)
Memory used 321,500k (± 0.02%) 321,470k (± 0.01%) -30k (- 0.01%) 321,372k 321,570k
Parse Time 1.56s (± 0.74%) 1.55s (± 0.61%) -0.01s (- 0.83%) 1.53s 1.57s
Bind Time 0.69s (± 0.65%) 0.69s (± 0.50%) -0.00s (- 0.15%) 0.68s 0.69s
Check Time 4.72s (± 0.71%) 4.70s (± 0.33%) -0.01s (- 0.30%) 4.67s 4.73s
Emit Time 2.80s (± 0.46%) 2.81s (± 0.85%) +0.01s (+ 0.36%) 2.78s 2.89s
Total Time 9.77s (± 0.47%) 9.75s (± 0.38%) -0.02s (- 0.16%) 9.70s 9.87s
TFS - node (v12.1.0, x64)
Memory used 286,527k (± 0.02%) 286,481k (± 0.01%) -46k (- 0.02%) 286,367k 286,538k
Parse Time 1.24s (± 0.36%) 1.24s (± 0.73%) -0.00s (- 0.24%) 1.22s 1.26s
Bind Time 0.64s (± 0.87%) 0.64s (± 1.05%) -0.00s (- 0.16%) 0.62s 0.65s
Check Time 4.33s (± 0.61%) 4.33s (± 0.44%) -0.00s (- 0.12%) 4.29s 4.38s
Emit Time 2.94s (± 0.64%) 2.93s (± 0.61%) -0.01s (- 0.44%) 2.90s 2.97s
Total Time 9.16s (± 0.46%) 9.14s (± 0.32%) -0.02s (- 0.22%) 9.05s 9.21s
material-ui - node (v12.1.0, x64)
Memory used 437,422k (± 0.05%) 437,092k (± 0.05%) -330k (- 0.08%) 436,257k 437,281k
Parse Time 2.04s (± 0.71%) 2.03s (± 0.58%) -0.01s (- 0.25%) 2.00s 2.05s
Bind Time 0.63s (± 0.71%) 0.63s (± 1.16%) -0.00s (- 0.63%) 0.62s 0.65s
Check Time 11.71s (± 0.84%) 11.69s (± 1.23%) -0.01s (- 0.12%) 11.48s 12.02s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.38s (± 0.71%) 14.35s (± 1.04%) -0.03s (- 0.20%) 14.12s 14.69s
Angular - node (v8.9.0, x64)
Memory used 340,104k (± 0.01%) 339,755k (± 0.02%) -349k (- 0.10%) 339,646k 339,899k
Parse Time 2.54s (± 0.47%) 2.54s (± 0.39%) 0.00s ( 0.00%) 2.52s 2.57s
Bind Time 0.85s (± 0.61%) 0.84s (± 0.62%) -0.01s (- 0.94%) 0.83s 0.85s
Check Time 5.40s (± 0.56%) 5.37s (± 0.45%) -0.03s (- 0.54%) 5.32s 5.44s
Emit Time 5.90s (± 1.41%) 5.90s (± 2.06%) +0.00s (+ 0.00%) 5.65s 6.24s
Total Time 14.69s (± 0.54%) 14.65s (± 0.87%) -0.04s (- 0.27%) 14.41s 15.01s
Monaco - node (v8.9.0, x64)
Memory used 340,340k (± 0.02%) 340,328k (± 0.01%) -12k (- 0.00%) 340,286k 340,424k
Parse Time 1.87s (± 0.48%) 1.88s (± 0.36%) +0.00s (+ 0.16%) 1.86s 1.89s
Bind Time 0.89s (± 0.54%) 0.89s (± 0.79%) +0.00s (+ 0.23%) 0.88s 0.90s
Check Time 5.47s (± 0.66%) 5.44s (± 0.60%) -0.03s (- 0.55%) 5.34s 5.50s
Emit Time 3.22s (± 0.78%) 3.22s (± 0.99%) +0.00s (+ 0.09%) 3.17s 3.33s
Total Time 11.45s (± 0.44%) 11.43s (± 0.52%) -0.02s (- 0.18%) 11.27s 11.55s
TFS - node (v8.9.0, x64)
Memory used 303,729k (± 0.01%) 303,759k (± 0.02%) +31k (+ 0.01%) 303,652k 303,862k
Parse Time 1.54s (± 0.44%) 1.55s (± 0.58%) +0.01s (+ 0.45%) 1.53s 1.57s
Bind Time 0.67s (± 0.71%) 0.67s (± 0.99%) -0.00s (- 0.45%) 0.66s 0.68s
Check Time 5.08s (± 1.38%) 5.10s (± 1.38%) +0.02s (+ 0.33%) 4.93s 5.21s
Emit Time 3.06s (± 2.93%) 2.98s (± 2.64%) -0.08s (- 2.62%) 2.87s 3.16s
Total Time 10.36s (± 0.37%) 10.30s (± 0.38%) -0.06s (- 0.60%) 10.21s 10.36s
material-ui - node (v8.9.0, x64)
Memory used 463,313k (± 0.01%) 463,037k (± 0.01%) -276k (- 0.06%) 462,977k 463,149k
Parse Time 2.39s (± 0.35%) 2.40s (± 0.63%) +0.01s (+ 0.59%) 2.38s 2.45s
Bind Time 0.78s (± 1.38%) 0.78s (± 1.08%) +0.00s (+ 0.00%) 0.76s 0.80s
Check Time 17.27s (± 0.81%) 17.30s (± 1.16%) +0.03s (+ 0.15%) 16.77s 17.84s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 20.44s (± 0.71%) 20.48s (± 0.99%) +0.04s (+ 0.19%) 19.92s 21.03s
Angular - node (v8.9.0, x86)
Memory used 195,162k (± 0.04%) 194,943k (± 0.03%) -219k (- 0.11%) 194,813k 195,081k
Parse Time 2.46s (± 0.60%) 2.45s (± 0.49%) -0.01s (- 0.45%) 2.42s 2.47s
Bind Time 0.99s (± 0.81%) 0.99s (± 0.59%) -0.00s (- 0.10%) 0.98s 1.00s
Check Time 4.84s (± 0.82%) 4.85s (± 0.87%) +0.01s (+ 0.25%) 4.78s 4.97s
Emit Time 5.91s (± 0.58%) 5.90s (± 0.53%) -0.01s (- 0.20%) 5.84s 5.98s
Total Time 14.19s (± 0.46%) 14.18s (± 0.50%) -0.01s (- 0.06%) 14.08s 14.39s
Monaco - node (v8.9.0, x86)
Memory used 193,450k (± 0.02%) 193,449k (± 0.03%) -2k (- 0.00%) 193,344k 193,573k
Parse Time 1.90s (± 0.44%) 1.93s (± 0.97%) +0.03s (+ 1.53%) 1.90s 1.98s
Bind Time 0.70s (± 0.57%) 0.70s (± 0.57%) 0.00s ( 0.00%) 0.69s 0.71s
Check Time 5.52s (± 0.40%) 5.52s (± 1.12%) -0.01s (- 0.13%) 5.29s 5.60s
Emit Time 2.66s (± 0.74%) 2.72s (± 2.89%) +0.05s (+ 2.07%) 2.63s 3.02s
Total Time 10.79s (± 0.30%) 10.86s (± 0.26%) +0.07s (+ 0.69%) 10.78s 10.91s
TFS - node (v8.9.0, x86)
Memory used 173,675k (± 0.02%) 173,690k (± 0.03%) +15k (+ 0.01%) 173,612k 173,783k
Parse Time 1.61s (± 1.22%) 1.59s (± 0.90%) -0.02s (- 1.06%) 1.57s 1.63s
Bind Time 0.64s (± 0.90%) 0.64s (± 0.90%) -0.00s (- 0.47%) 0.63s 0.66s
Check Time 4.68s (± 0.53%) 4.67s (± 0.64%) -0.00s (- 0.09%) 4.63s 4.76s
Emit Time 2.79s (± 1.18%) 2.76s (± 1.26%) -0.03s (- 1.01%) 2.67s 2.81s
Total Time 9.71s (± 0.60%) 9.66s (± 0.54%) -0.05s (- 0.54%) 9.54s 9.79s
material-ui - node (v8.9.0, x86)
Memory used 262,396k (± 0.01%) 262,266k (± 0.02%) -130k (- 0.05%) 262,150k 262,376k
Parse Time 2.45s (± 0.64%) 2.45s (± 0.91%) +0.00s (+ 0.12%) 2.39s 2.50s
Bind Time 0.67s (± 1.67%) 0.67s (± 1.52%) -0.00s (- 0.15%) 0.65s 0.69s
Check Time 15.67s (± 0.66%) 15.73s (± 0.75%) +0.06s (+ 0.41%) 15.51s 16.01s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.78s (± 0.61%) 18.85s (± 0.70%) +0.07s (+ 0.36%) 18.61s 19.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)
Benchmark Name Iterations
Current 39698 10
Baseline master 10

@IllusionMH
Copy link
Contributor Author

@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
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs 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