-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Interactive way to query compilers (e.g. "What is the type of <my expression>?") #17505
Comments
if this is just for learning purposes and not meant to be part of an program, you can use
|
Example: I have N string literals known at compile time that I would like to pass to a utility function that will loop through them. Slices are great as they keep track of the length, so naturally I just make the function argument accept type But then no amount of coaxing at the call site, whether using slice notation or putting it through layers of pointer casting would let the function accept the type, so I have no idea whether the mistake is happening at the callsite or at the argument definition, the compiler error does not give any useful indication of what the type is supposed to be. |
I think the main problem here is that the error message isn't descriptive enough. It's probably just a simple issue, like a forgotten const: Also: Next time it would be better to ask for help in one of zig's community spaces first. You'll usually get a faster answer there. |
There is a proposal that would enable a feature like this to be added #615 |
I'm tripping up with strings and pointers and comptime, and when I try to write a throwaway script to tell me what the types of certain expression are, the debug print statement itself errors out or just straight up crashes without printing any output whatsoever.
All I want to do is to be able to ask the compiler what is the type that it thinks my expression is, without dealing with the catch-22 of needing to know what that answer is in order to get it to print the answer in the first place.
The text was updated successfully, but these errors were encountered: