GNOME Bugzilla – Bug 762377
Annotate functions with default return value
Last modified: 2018-05-22 15:31:25 UTC
As discussed on IRC, it would be important to have the possibility of specifying a return value when an error is thrown. The GIO stream APIs (read and write) expect '-1' to be returned along with the GError. http://valadoc.org/#!api=gio-2.0/GLib.OutputStream.write A CCode annotation would be necessary for functions throwing errors with a C expression: [CCode (return_value_on_error = "-1")] public override ssize_t write (uint8[] buffer) throws IOError { throw new IOError.FAILED (""); } That would target C code, because a Vala caller would not be able to obtain the return value. I might be interesting to consider the possibility of obtaining the return value in a try {} catch construct.
Created attachment 321735 [details] Testcase that cover a failing implementation of GLib.OutputStream It is impossible to implement GLib.OutputStream correctly if an error has to be thrown, because the default returned value is '0'.
Just to add: all Vala implementations of FilterInputStream and FilterOutputStream are inexorably broken: they will suffer from the 'write_all' loop.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/526.