-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Inconsistant Span of Ident inside BindingIdent #8856
Comments
It seems this bug fix doesn't match my expectation. The current behavior is as follows. const a: number = 0;
// binding ident: 7, 8
// ident: 7, 8
// typeAnn: 10, 16 That seems to be a bit weird because the span of typeAnn is out of the span of binding ident though the typeAnn belongs to the binding ident. My expectation is as follows. const a: number = 0;
// binding ident: 7, 16
// ident: 7, 8
// typeAnn: 10, 16 |
It' s not possible because |
That's still confusing to me. BindingIdent supports |
I don't think it's good idea. BindingIdent should deref to Id and it will make .span and .span() different |
Alright, thanks for the explanation. |
I just fixed that at my side by this commit. let span = if let Some(type_ann) = self.type_ann.as_ref() {
Span {
lo: self.id.span.lo,
hi: type_ann.as_ref().span.hi,
ctxt: self.id.span.ctxt,
}
} else {
self.span()
}; |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
I found the span of Ident inside BindingIdent is inconsistant. Here are 2 cases.
Case 1: BindingIdent doesn't Include TsTypeAnn
Case 2: BindingIdent Includes TsTypeAnn
Conclusions
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.100&code=H4sIAAAAAAAAA0srzUsuyczPU0jSSLRSyCvNTUotUrBVMNRUqK4FAOamXN8cAAAA&config=H4sIAAAAAAAAA1VPOw7DIAzdcwrkuUOUoUPv0EMg6kRE%2FIRdqSjK3QsB0maz38fveRuEgJUUPMSWx7wEGQnjuWeEkmP5yQhwCkgq6sBw6yxToWZpCA9orwywjAtycSFN4zQ2BxjvCbujYVY7Paf%2FTOVtiEh0FRapdIvBa%2BLQUsH61%2Fsg2y%2Blb21wh5%2Boh52HQdOzO%2BvZ%2FQtlF66JGAEAAA%3D%3D
https://play.swc.rs/?version=1.4.13&code=H4sIAAAAAAAAA0srzUsuyczPU0jSSLRSyCvNTUotUrBVMNRUqK4FAOamXN8cAAAA&config=H4sIAAAAAAAAA1VPOw7DIAzdcwrkuUOUoUPv0EMg6kRE%2FIRdqSjK3QsB0maz38fveRuEgJUUPMSWx7wEGQnjuWeEkmP5yQhwCkgq6sBw6yxToWZpCA9orwywjAtycSFN4zQ2BxjvCbujYVY7Paf%2FTOVtiEh0FRapdIvBa%2BLQUsH61%2Fsg2y%2Blb21wh5%2Boh52HQdOzO%2BvZ%2FQtlF66JGAEAAA%3D%3D
SWC Info output
No response
Expected behavior
The span of BindingIdent and Ident should be consistant.
Actual behavior
No response
Version
Additional context
No response
The text was updated successfully, but these errors were encountered: