-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Make C pointers require a keyword. #18352
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
Conversation
|
I haven't looked through the diff properly, but here are some comments at a glance.
|
|
Thank you for the comments. I have no strong opinions on any of the methods I used, so I would be happy to move this to AstGen (will do shortly).
Understood, will do so. My concern comes from "outsiders" looking at the stdlib as a learning material and seeing this token strewn around everywhere, and make incorrect assumptions, whatever they may be. But again, no strong opinion, if you believe it best to simply update all of the affected files, that is what I'll do.
Apologies, I just realized that I never marked this PR a draft. I meant for this to be the first stage to get other's opinions on my approach. I plan on making sure it's all correct! |
3a8bde4 to
50d9903
Compare
| @@ -1,3 +1,5 @@ | |||
| thisfileisautotranslatedfromc; | |||
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.
Maybe this has been discussed already, but for the uncommon correct uses of C pointers in std (testing functionality that interacts with them), how about using @Type to programmatically construct C pointer types? Since the check is implemented in AstGen, I believe that should still work, and it would avoid having to infect the entire file with the autotranslated status.
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.
This was discussed, and that was the consensus iirc.
If you look at my checklist I still have to look through the stdlib uses of the keyword and see if they are truly needed. I will construct with with @Type if they actually are needed 👍
| @@ -1,3 +1,5 @@ | |||
| thisfileisautotranslatedfromc; | |||
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.
This file is not auto translated from 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.
Yes, I know. Please note that I still need to go through the instances of thisfileisautotranslatedfromc; that needed to be added, and determine which ones are actually needed. As I said in Ian's review, I will construct them from @Type if they are truly needed.
|
I'm sorry, I didn't review this in time, and now it has bitrotted. Furthermore, so many pull requests have stacked up that I can't keep up and I am therefore declaring Pull Request Bankruptcy and closing old PRs that now have conflicts with master branch. If you want to reroll, you are by all means welcome to revisit this changeset with respect to the current state of master branch, and there's a decent chance your patch will be reviewed the second time around. Either way, I'm closing this now, otherwise the PR queue will continue to grow indefinitely. |
this fixes #2984
this adds a
is_autotranslatedflag tostd.zig.Astas well asstd.zig.Parser. my solution is to create a keyword that only exists in the parser, which when seen updates the flag. the main error logic is handled inside of AstGen, so that if need be, this can be used for other things that might be constrained by an auto generated file. i intentionally do not add the token to the node list for 2 important reasons. first, it has no actual meaning in the code and is simply a "metadata" tag. second, it would mess up a lot of logic that relies on optimizing empty structs, and other checks. it simply makes no sense to spend the time on processing something that gives nothing.note that the wasm blob needed to be updated because of this syntax affecting stage1
TODO:
outdated, initial message, to give context to mlugg's reply
first,
the solution is a bit strange, but i believe it's the cleanest one. the main problem i faced when implementing this was that making this a "full" token, and appending it to the list would trip a lot of different
decls.len == 0type logic. could i have created special cases for those comparisons, yes. but that would have been a bit unclean and required more code change. i dont see this as a real token, i just think of it as a file descriptor.second,
you may notice that this error is turned off inside of test blocks. this was not a requirement of the issue, however i see no other way around this. either we could update 500 files with the token, or just let c pointers exist inside of test blocks. there is no other usage for c pointers in my opinion other than for testing.
third,
all of the stdlib changes you see, i simply moved
[*c]to[*]. this is possibly not the correct solution, however i just dont know that specific code to tell. please tell me if there is something else that should be used.i believe this pr is a move forward in the right direction. it's a big breaking change, and is something that should be thought through very carefully, so take your time.
any feedback is very welcome, i only felt confident enough to pr this once the testing suite completed on my machine completed.
(you may notice my shift key is a bit dead)