Skip to content

Allow duplicate identifiers across declarations.#8696

Merged
RyanCavanaugh merged 1 commit into
microsoft:masterfrom
RyanCavanaugh:fix8675
May 24, 2016
Merged

Allow duplicate identifiers across declarations.#8696
RyanCavanaugh merged 1 commit into
microsoft:masterfrom
RyanCavanaugh:fix8675

Conversation

@RyanCavanaugh
Copy link
Copy Markdown
Member

Fixes #8675

Duplicate identifiers within the same block are still disallowed. Additionally, we retain the restriction that the types of the declared symbols must be identical.

Comment thread src/compiler/checker.ts Outdated
}

if (hasProperty(names, memberName)) {
error(member, Diagnostics.Duplicate_identifier_0, memberName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

member.name for the error range.

Copy link
Copy Markdown
Contributor

@mhegazy mhegazy May 19, 2016

Choose a reason for hiding this comment

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

We report the duplicate declaration errors on all declarations, as ppl complained they could not find the other one when we reported only on one declaration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wonder if we need to keep doing that since now it's guaranteed to be in the same block

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i see. yeah you are probably right.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented May 19, 2016

do not see the handling for optionality.

Comment thread src/compiler/checker.ts Outdated

if (hasProperty(names, memberName)) {
error(member.symbol.valueDeclaration, Diagnostics.Duplicate_identifier_0, memberName);
error(member, Diagnostics.Duplicate_identifier_0, memberName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

member.name to get a better error span.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented May 23, 2016

also can you add a test for computed properties

class C {
    ["a"]: 1,
    ["a"]: 2
}

@RyanCavanaugh
Copy link
Copy Markdown
Member Author

Last call

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants