-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
don't allow a token starting with an asterisk directly following .* #6858
Conversation
You have to also change this in |
Sounds good, I noticed the zig tokenizer a few minutes ago and was gonna ask if I should mirror the changes there. |
lib/std/zig/tokenizer.zig
Outdated
@@ -1001,6 +1000,17 @@ pub const Tokenizer = struct { | |||
}, | |||
}, | |||
|
|||
.period_asterisk => switch (c) { | |||
'*' => { | |||
result.id = .Invalid; |
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.
To get a proper error message you have to give this a new tag. You should be able to copy what I did with .Invalid_ampersands
.
ee31d65
to
d7f9128
Compare
So just to make sure I understand, you're returning a valid node since it actually is a complete token even though it's illegal for it to be directly followed by an asterisk? So it's more of a style error than an "I don't know how to continue to parse from here" error. Edit: Never mind, answered in Discord. |
@@ -323,6 +326,7 @@ pub const Error = union(enum) { | |||
pub const ExtraAllowZeroQualifier = SimpleError("Extra allowzero qualifier"); | |||
pub const DeclBetweenFields = SimpleError("Declarations are not allowed between container fields"); | |||
pub const InvalidAnd = SimpleError("`&&` is invalid. Note that `and` is boolean AND."); | |||
pub const AsteriskAfterPointerDereference = SimpleError("`.*` can't be followed by `*`. Are you missing a space?"); |
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.
There are 2 spaces before Are you missing a space?
.
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.
That's the user's missing space, silly!
closes #6823
I couldn't find where the tests are for the tokenizing so if one needs added if you could point me in the right direction that'd be great