question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C_NUMBER_RE has incorrect behavior with unary `-`

See original GitHub issue

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
joshgoebelcommented, Nov 25, 2020

Ah okay so you want to exclude - from the number token globally.

Yes, that has been the general rule because it’s mostly impossible to simply know if the - is an operator or a unary on a number (without being a full parser).

We can’t look backwards yet… so all we see is “-3”… so is that:

[operator]- [number]3
OR
[number]-3

Just flagged it as an operator always (or not flagging it at all) has the appears of us making fewer ‘mistakes’.

1reaction
joshgoebelcommented, Nov 25, 2020

Huh? Not sure I’m following. If that was program code the - would be an operator and the 8 would be a number in many languages.

The discussion here is about changing the C_NUMBER to exclude - from the beginning of numbers - like our general policy has been.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No warning when using unary +/- operators on functions and ...
Unary + or - is only applicable to a number or maybe a string . I would expect the lines listed as //...
Read more >
Unary plus (+) - JavaScript - MDN Web Docs
The unary plus (+) operator precedes its operand and evaluates to its operand but attempts to convert it into a number, if it...
Read more >
Can someone explain why sizeof() returns these values with ...
Yes, the unary + and - operators integer promote small integer types to int . C17 6.5.3.3: The result of the unary +...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found