-
Notifications
You must be signed in to change notification settings - Fork 656
fix(rome_js_analyzer, rome_js_parser): suppress false positive diagnostics related to index signature parameter #4660
Conversation
redeclarations.push(Redeclaration { | ||
name, | ||
declaration: *first_text_range, | ||
redeclaration: id_binding.syntax().text_trimmed_range(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule no longer handles the case like interface A { [index: number]: string; [index: number]: string; }, so I removed unnecessary logic.
✅ Deploy Preview for docs-rometools ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -24,7 +24,5 @@ | |||
"function f() { var a; var a; }", | |||
"function f() { var a; if (test) { var a; } }", | |||
"for (var a, a;;);", | |||
"for (;;){ var a, a,;}", | |||
"function f(x) { var x = 5; }", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case was not correctly checked, so I removed. (see: #4291)
@@ -24,7 +24,5 @@ | |||
"function f() { var a; var a; }", | |||
"function f() { var a; if (test) { var a; } }", | |||
"for (var a, a;;);", | |||
"for (;;){ var a, a,;}", | |||
"function f(x) { var x = 5; }", | |||
"interface A { [index: number]: string; [index: number]: string; }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semantic analyzer no longer handle this case, so I removed.
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
🔥 Regression (28):
ts/babel
ts/microsoft
|
@nissy-dev have you looked at the regressions? Seems like the change of logic broke some test |
@ematipico I'll check it in a few days! But, I have never seen these |
No worries! In Rome we have some conformance tests that run against some code bases, and one of them in the TypeScript repository. We do that using git submodules. Our test suite runs against TypeScript conformance tests, and we check if our parser and their parser result match. If our parser doesn't match TS result, it's a fail. In your case, it seems that what we could parse, now doesn't parse anymore as expected. The files listed in the comment come from the TypeScript repository, here's an example:
Our test suite parsers the symbol file to collect the correct data, and eventually we run it using our Now, I don't precisely know the assertions that we do against our parser and what caused the regression, unfortunately. Although, a regression is something that we should not overlook. Something to consider: the TS parser identifies those as normal identifiers. Try to hover |
@ematipico Thank you for your thoughtful comments! After checking these regressions, the reason is that the conformance test depends on the semantic analyzer. tools/xtask/coverage/src/symbols/msts.rs Line 83 in 54b2ab7
Considering this point, the regressions are reasonable, so we can ignore.
Because of the reason, I confirmed the regressions will also happens even if I fix it as you pointed out. |
I believe it's fine if you decide to create a new node, but I think that the semantic analyzer should be updated to track the new node as a symbol. It's fine if we fix the rules, but I think it's not fine if we regress the conformance without a specific reason. |
The symbol collected in this conformance test is some kinds of the semantic events. Implementation: tools/xtask/coverage/src/symbols/msts.rs Lines 83 to 101 in 54b2ab7
In my PR, the semantic analyzer no longer push the semantic event when entering an identifier binding node of index signatures. Your suggestion is that it would be better to solve this issue while handling an identifier binding of index signatures as the semantic event? I am not sure if this is possible yet. I have felt that many of the semantic analyzer functions don't take into account the identifier of index signatures, so a lot of changes may be needed. |
I know. Although, I think this is not the correct fix. For example, the So, as long as we want to add a new node, we should still keep tracking it in the semantic analyzer. Then, inside the |
OK! I will try to reimplement it with your remarks in mind. |
Summary
Fix #4634
The reason of this issue is that semantic analyzer handles index signature parameter as JsIdentifierBinding.
Thus, I add a new CST Node, TsIndexSignatureIdentifierBinding and suppress false positive diagnostics.
Test Plan
I update some snapshot tests.