C_NUMBER_RE has incorrect behavior with unary `-`
See original GitHub issueThat makes sense.
I modeled my regex after the C_NUMBER_RE
which starts with -?
:
https://github.com/highlightjs/highlight.js/blob/3a2934d7e7af99631527bf55465fa229522735b9/src/lib/modes.js#L8
_Originally posted by @Hirse in https://github.com/highlightjs/highlight.js/pull/2808#discussion_r528422486_
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
Just flagged it as an operator always (or not flagging it at all) has the appears of us making fewer ‘mistakes’.
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.