-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Allow shorter signed hex literals with appropriate type suffixes #11844
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
Allow shorter signed hex literals with appropriate type suffixes #11844
Conversation
See PowerShell#11823 for context and discussion. This change allows shorter hex literals to be treated as signed, if the specified type suffix is a signed type with correct hex lengths. For example, 0xFFFFs now parses correctly to -1 instead of erroring.
|
|
||
|
|
||
| // If we're expecting a sign bit, remove the leading 0 added in ScanNumberHelper | ||
| if (!suffix.HasFlag(NumberSuffixFlags.Unsigned)) |
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.
Why is this a dup of 3700 line?
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.
Oh, weird. Guessing a copy-paste error. Thanks for noticing that! I'll edit the duplicate segment out. 💖
2900fd4 to
dfe7feb
Compare
iSazonov
left a comment
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.
LGTM with one minor comment.
| if (strNum == null) | ||
| { return ScanGenericToken(c); } |
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.
Formatting.
|
@daxian-dbw The change is in the tokenizer, I would like you to have a look. |
|
🎉 Handy links: |
|
BackPort-7.0.x-Consider is asked in #14302 |
|
@SteveL-MSFT / @joeyaiello We need you comment about whether this should be back ported to 7.0.x? |
|
@SteveL-MSFT Do we want to backport this? |
PR Summary
This change allows shorter hex literals to be treated as signed, if the specified type suffix is a signed type with correct hex lengths. For example,
0xFFFFsnow parses correctly to -1 instead of erroring. Default behaviour without a specific suffix and/or with explicit unsigned suffixes remains as it was.PR Context
Resolves #11823. See the issue for further context and discussion.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.