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

LSP: add call inlays for complex literals #25202

Merged
merged 6 commits into from
Jun 10, 2024

Conversation

DanilaFe
Copy link
Contributor

@DanilaFe DanilaFe commented Jun 10, 2024

Closes #25115.

This just involves adding some smarter AST inspection to detect what we want to treat like "literals" for the purposes of call inlays. Specifically, I've opted for the following:

  1. Complex number literals should only have 'two' components; in the same way that 1+1 is not a literal, neither is 1 + 1i + 1. On the other hand, 1 + 1i is a literal.
  2. The numbers can be in any order: 1 + 1i or 1i + 1. This is a bit liberal, but I think it's reasonable.
  3. Double negation is not allowed, neither for real/imaginary numbers nor complex literals.
  • So, -4 is a "literal", but - -4 is not.
  • Similarly, 4 - (-i) is not a literal.

I've un-xfailed the test that locked this down, and added a separate test for negative numbers.

Reviewed by @jabraham17 -- thanks!

Testing

  • make test-cls

Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Node, Jade, I did not get bitten by the CI check :^)

Signed-off-by: Danila Fedorin <[email protected]>
@DanilaFe DanilaFe requested a review from jabraham17 June 10, 2024 16:22
@DanilaFe DanilaFe merged commit 324cb1a into chapel-lang:main Jun 10, 2024
8 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.

[Bug]: CLS does not treat negative numbers and complex numbers as literals
2 participants