-
-
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
Possible compiler issue #3381
Comments
See #591 -- this is a known footgun and an open issue. Please note the age of the case does not reflect how serious this issue is taken. It's just not a simple one to solve when considering the rest of the language - like sussing out interface support etc.
unfortunately for this case the types var obj: Foo = Foo{};
var ptr: *Foo = &obj;
obj.run();
ptr.run(); |
Thanks for the explanation. I'm going to leave this open for Andrew et al to decide whether this issue adds anything to finding a solution to this. As for your comment about the age of the case, I do understand that this project is a big job. I've looked at some of the release notes and see the progress that has been made. So I certainly don't have the impression that the developers have taken an extended vacation or aren't working on things that are important. Speaking of which, I would like to bang the documentation drum again. In general, the current documentation, while it conveys a lot of information in few words, still really needs fleshing out in order to get to 1.0. And I'm not telling you anything you don't already know when I say that a standard library document should also be a high priority. I know -- there are more high priority items than people. |
#591 remains open and it's one of the issues I want to address during this release cycle, with additional safety checks. |
I want to open an output file to which I can both simply write and also do a formatted print, the analogy to fprintf.
There really isn't any documentation yet for this, so I picked through the code in zig/std. In std/debug.zig, I find the getStderrStream function, which I used as a guide. After running into trouble, I excerpted the problem code into a little example.
If I simply run this file, I get:
No compilation errors, but the output does not go to /tmp/foo.bar, but to stdout instead.
Realizing that io.Stream.print wants &self, I change the example:
Now it works correctly.
But the print function is defined as
So I would have expected a type mis-match in compiling the first, incorrect version of the example. That's not what happened. It compiled without error and I got incorrect behavior instead.
The text was updated successfully, but these errors were encountered: