Skip to content
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

fix(57635): duplicate property name error when trying to overwrite early-bound prop with late-bound prop #57717

Merged
merged 3 commits into from
Mar 26, 2024

Conversation

idango10
Copy link
Contributor

Fixes #57635


As written in the issue, I noticed there's a conflict in which the late-bound member already exists as an early-bound member.

My naive approach was to remove earlySmybol from the if statement and see which tests are failing, and I saw that dynamicNamesErrors.ts was the only test to fail (https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicNamesErrors.ts#L6-L12).

I thought there's a reason for that, and that Function should behave differently from Interface, but they appear to behave similarly in that case.

In the example below, you can see that when one prop is early-bound and the second is late-bound, there's an error pointing to duplication. However, when they are both early-bound or late-bound, there are no errors (TS Playground):

const c0 = "1";
const c1 = '1';

interface T0 {
    [c0]: number; // Error: Duplicate property '1'.(2718)
    1: number; // Error: Property '1' was also declared here.(2733)
}

// No errors
interface T1 {
    ['1']: number;
    1: number;
}

// No errors
interface T2 {
    [c0]: number;
    [c1]: number;
}

I think that regardless of whether we want to forbid or allow duplications in functions and interfaces, it should be consistent, and not inside lateBindMember.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Mar 11, 2024
Comment on lines 15 to -22
[c0]: number;
~~~~
!!! error TS2718: Duplicate property '1'.
1: number;
~
!!! error TS2733: Property '1' was also declared here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say that this sure felt wrong, but your playground link does show that doing effectively this in other forms does not error. (Makes me wonder if we're missing errors; but that's more of a design question I don't have context for.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should allow it, but it's definitely a separate question -- and disallowing it will probably break some amount of code.

@jakebailey
Copy link
Member

@typescript-bot test top400
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot perf test this faster
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 11, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started 👀 Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results
pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 11, 2024

Hey @jakebailey, 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/160257/artifacts?artifactName=tgz&fileId=FADC14EF3BE001EA30400BC5AFEFC62B5FCFCF22B1B14F31164637BE8782012A02&fileName=/typescript-5.5.0-insiders.20240311.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.5.0-pr-57717-2".;

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/57717/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,537k (± 0.01%) 295,533k (± 0.01%) ~ 295,513k 295,561k p=0.336 n=6
Parse Time 2.66s (± 0.24%) 2.66s (± 0.19%) ~ 2.66s 2.67s p=0.386 n=6
Bind Time 0.83s (± 0.00%) 0.83s (± 0.76%) ~ 0.82s 0.84s p=1.000 n=6
Check Time 8.23s (± 0.27%) 8.21s (± 0.32%) ~ 8.16s 8.24s p=0.169 n=6
Emit Time 7.14s (± 0.40%) 7.13s (± 0.54%) ~ 7.08s 7.18s p=0.334 n=6
Total Time 18.86s (± 0.27%) 18.83s (± 0.25%) ~ 18.78s 18.90s p=0.334 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,145k (± 0.73%) 192,091k (± 0.75%) ~ 191,387k 194,996k p=0.575 n=6
Parse Time 1.36s (± 1.01%) 1.35s (± 0.73%) ~ 1.33s 1.36s p=0.059 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.38s (± 0.26%) 9.37s (± 0.37%) ~ 9.32s 9.42s p=0.465 n=6
Emit Time 2.61s (± 0.93%) 2.61s (± 0.51%) ~ 2.59s 2.63s p=0.803 n=6
Total Time 14.07s (± 0.39%) 14.04s (± 0.26%) ~ 14.00s 14.09s p=0.421 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,302k (± 0.00%) 347,319k (± 0.01%) ~ 347,300k 347,349k p=0.173 n=6
Parse Time 2.47s (± 0.30%) 2.49s (± 0.47%) +0.02s (+ 0.67%) 2.47s 2.50s p=0.032 n=6
Bind Time 0.93s (± 0.56%) 0.93s (± 0.56%) ~ 0.92s 0.93s p=1.000 n=6
Check Time 6.94s (± 0.46%) 6.95s (± 0.45%) ~ 6.90s 6.99s p=0.629 n=6
Emit Time 4.05s (± 0.21%) 4.07s (± 0.43%) +0.02s (+ 0.45%) 4.06s 4.10s p=0.040 n=6
Total Time 14.40s (± 0.20%) 14.43s (± 0.12%) +0.04s (+ 0.24%) 14.41s 14.45s p=0.043 n=6
TFS - node (v18.15.0, x64)
Memory used 302,775k (± 0.01%) 302,755k (± 0.01%) ~ 302,731k 302,775k p=0.149 n=6
Parse Time 2.00s (± 0.69%) 2.02s (± 0.73%) +0.02s (+ 1.17%) 2.00s 2.04s p=0.029 n=6
Bind Time 1.00s (± 0.81%) 1.00s (± 1.22%) ~ 0.99s 1.02s p=0.730 n=6
Check Time 6.32s (± 0.38%) 6.34s (± 0.51%) ~ 6.30s 6.39s p=0.255 n=6
Emit Time 3.60s (± 0.52%) 3.60s (± 0.42%) ~ 3.58s 3.62s p=0.743 n=6
Total Time 12.92s (± 0.20%) 12.96s (± 0.14%) +0.04s (+ 0.31%) 12.93s 12.98s p=0.023 n=6
material-ui - node (v18.15.0, x64)
Memory used 511,249k (± 0.02%) 511,250k (± 0.01%) ~ 511,215k 511,326k p=0.128 n=6
Parse Time 2.65s (± 0.75%) 2.64s (± 0.66%) ~ 2.63s 2.67s p=0.931 n=6
Bind Time 0.98s (± 1.06%) 0.99s (± 1.04%) ~ 0.98s 1.00s p=0.203 n=6
Check Time 17.26s (± 0.50%) 17.28s (± 0.58%) ~ 17.20s 17.48s p=0.629 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.89s (± 0.47%) 20.92s (± 0.56%) ~ 20.84s 21.15s p=0.572 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,789,577k (± 0.00%) 1,789,583k (± 0.00%) ~ 1,789,532k 1,789,656k p=0.689 n=6
Parse Time 6.63s (± 0.42%) 6.63s (± 0.48%) ~ 6.60s 6.69s p=0.936 n=6
Bind Time 2.39s (± 0.22%) 2.39s (± 0.49%) ~ 2.37s 2.40s p=0.195 n=6
Check Time 58.97s (± 0.33%) 59.05s (± 0.43%) ~ 58.70s 59.45s p=0.687 n=6
Emit Time 0.16s (± 2.52%) 0.16s (± 3.16%) ~ 0.16s 0.17s p=0.595 n=6
Total Time 68.16s (± 0.27%) 68.24s (± 0.38%) ~ 67.89s 68.62s p=0.688 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,393,966k (± 0.02%) 2,394,174k (± 0.03%) ~ 2,393,343k 2,395,312k p=0.689 n=6
Parse Time 5.03s (± 0.34%) 5.05s (± 0.97%) ~ 5.02s 5.15s p=0.422 n=6
Bind Time 1.89s (± 0.82%) 1.89s (± 1.13%) ~ 1.85s 1.91s p=1.000 n=6
Check Time 33.65s (± 0.24%) 33.71s (± 0.40%) ~ 33.57s 33.92s p=0.575 n=6
Emit Time 2.67s (± 1.54%) 2.70s (± 0.41%) ~ 2.68s 2.71s p=0.107 n=6
Total Time 43.26s (± 0.08%) 43.36s (± 0.29%) ~ 43.21s 43.54s p=0.128 n=6
self-compiler - node (v18.15.0, x64)
Memory used 414,491k (± 0.01%) 414,500k (± 0.00%) ~ 414,474k 414,525k p=0.378 n=6
Parse Time 2.81s (± 0.85%) 2.79s (± 1.00%) ~ 2.76s 2.84s p=0.287 n=6
Bind Time 1.07s (± 0.51%) 1.06s (± 0.49%) ~ 1.06s 1.07s p=0.640 n=6
Check Time 15.13s (± 0.20%) 15.20s (± 0.59%) ~ 15.08s 15.30s p=0.171 n=6
Emit Time 1.11s (± 1.27%) 1.11s (± 1.09%) ~ 1.09s 1.12s p=0.743 n=6
Total Time 20.11s (± 0.23%) 20.17s (± 0.53%) ~ 20.04s 20.31s p=0.514 n=6
vscode - node (v18.15.0, x64)
Memory used 2,866,180k (± 0.00%) 2,866,191k (± 0.00%) ~ 2,866,159k 2,866,209k p=0.810 n=6
Parse Time 10.78s (± 0.36%) 10.79s (± 0.24%) ~ 10.76s 10.83s p=0.520 n=6
Bind Time 3.46s (± 0.77%) 3.45s (± 0.46%) ~ 3.43s 3.47s p=0.802 n=6
Check Time 60.96s (± 0.61%) 60.90s (± 0.23%) ~ 60.74s 61.13s p=0.689 n=6
Emit Time 16.88s (± 8.85%) 16.28s (± 0.44%) ~ 16.20s 16.36s p=0.872 n=6
Total Time 92.07s (± 1.98%) 91.42s (± 0.19%) ~ 91.15s 91.65s p=0.575 n=6
webpack - node (v18.15.0, x64)
Memory used 397,041k (± 0.01%) 397,055k (± 0.01%) ~ 397,013k 397,115k p=0.689 n=6
Parse Time 3.12s (± 0.62%) 3.12s (± 0.63%) ~ 3.10s 3.15s p=0.685 n=6
Bind Time 1.38s (± 1.52%) 1.37s (± 1.26%) ~ 1.34s 1.39s p=0.511 n=6
Check Time 14.00s (± 0.36%) 13.96s (± 0.54%) ~ 13.84s 14.04s p=0.624 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 18.50s (± 0.23%) 18.46s (± 0.40%) ~ 18.33s 18.53s p=0.331 n=6
xstate - node (v18.15.0, x64)
Memory used 513,186k (± 0.02%) 513,162k (± 0.02%) ~ 513,096k 513,297k p=1.000 n=6
Parse Time 3.27s (± 0.23%) 3.27s (± 0.26%) ~ 3.27s 3.29s p=0.652 n=6
Bind Time 1.54s (± 0.26%) 1.54s (± 0.49%) ~ 1.53s 1.55s p=0.389 n=6
Check Time 2.86s (± 0.87%) 2.87s (± 1.23%) ~ 2.84s 2.92s p=0.934 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 7.76s (± 0.32%) 7.77s (± 0.48%) ~ 7.72s 7.81s p=0.871 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/57717/merge:

Everything looks good!

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct, although the preceding comment needs simplification.

@@ -12997,7 +12997,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// conflicting flags.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update this comment to read "Report an error if there's a symbol declaration with the same name and conflicting flags.", since there's no longer an error for any earlySymbol with the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 🙂

@idango10 idango10 requested a review from sandersn March 20, 2024 16:25
@sandersn sandersn self-assigned this Mar 26, 2024
@sandersn sandersn merged commit 316f180 into microsoft:main Mar 26, 2024
25 checks passed
@idango10 idango10 deleted the fix/57635 branch March 26, 2024 15:48
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.

Duplicate property name error when accessing an expando function in diffrent ways.
4 participants