Skip to content

Lint against re-declaring parameters#679

Merged
bakkot merged 2 commits intotc39:mainfrom
nicolo-ribaudo:lint-param-re-let
Mar 26, 2026
Merged

Lint against re-declaring parameters#679
bakkot merged 2 commits intotc39:mainfrom
nicolo-ribaudo:lint-param-re-let

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Member

Linting for tc39/ecma262#3768. This is probably not going to catch every single case, but it should catch the majority.

With this change we get a false positive in ValidateAndApplyPropertyDescriptor step 6.c.i:

1. For each field of _Desc_, set the corresponding attribute of the property named _P_ of object _O_ to the value of the field.

because Desc is the first variable defined after for each, so ecmarkup thinks that we are re-declaring it. It would report the same error for this algorithm, even if Desc was not a parameter:

1. Let _Desc_ be SomehowGetDesc()
1. For each field of _Desc_, set the corresponding attribute of the property named _P_ of object _O_ to the value of the field.

If we want to lint for re-declared parameters, we can update that loop to instead do something like

1. For each field name _F_ of _Desc_, set the attribute _F_ of the property named _P_ of object _O_ to the value of the field.

so that ecmarkup doesn't think that that step is declaring Desc.

Copy link
Copy Markdown
Member

@bakkot bakkot left a comment

Choose a reason for hiding this comment

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

The change to ValidateAndApplyPropertyDescriptor SGTM. Want to open and land that change first, then we can land this?

@bakkot bakkot merged commit b0ebb9f into tc39:main Mar 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants