I was just reading some zig code related to tokenizer and parser as I was interested in how it works. Some light night reading as one do before bed.
I have spotted possibly copy paste typo. It probably will have no effect as the function that is called will already check the 0 but wanted to ask if that was intended or it is copy paste error ?
Lines: 3820 and 3821
const else_expr = try bodyParseFn(p);
assert(then_expr != 0);
I would suspect that the assert was intended for else_expr since few lines above is:
const then_expr = try bodyParseFn(p);
assert(then_expr != 0);
Please let me know if I am correct or it was intended that way.
Yes this does seem to be a typo, I’d recommend submitting a pull request to the repo. If you would prefer not just let me know and I can submit one. If accepted, it will give you the contributor tag though on Github for the Zig repo.
If it is intended behavior, they will let you know.
Btw, I’ve edited your post to make it more readable. By linking to the source code you are mentioning as well as using code blocks it makes it much easier for others to help. If you click edit on your post you will be able to see specifically what I have done. I just used the buttons located just above the text editor. With code blocks if you add ‘zig’ after them it will add syntax highlighting.
Thank you for your reply. I would prefer if you submit the pull request as I am not too familiar with the process and don’t have much time with three kids. I am just learning zig as hobby in my limited time. You can link the pull request and I can see what you have done for the simple issue like this. Also I would like to know what is the best way if I find another issue. Is it ok to post here or better to learn process and create pull request as it saves duplication of posting ? I know I could learn the process I just don’t want to start and then not reply for days.
No worries at all, glad to have you here!
You can view the pull request here: std.zig.Parse: Fix assert target by zraineri · Pull Request #16500 · ziglang/zig · GitHub
With something this simple I would just edit it right on github:
Select master and then click the edit icon
It’s okay to post here if you’re unsure, but it would probably make more sense to create an issue: Issues · ziglang/zig · GitHub
Thank you. You were really helpful with examples and edits I feel I have learned something.