After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762377 - Annotate functions with default return value
Annotate functions with default return value
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator: GError
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-20 18:34 UTC by Guillaume Poirier-Morency
Modified: 2018-05-22 15:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase that cover a failing implementation of GLib.OutputStream (473 bytes, text/plain)
2016-02-20 19:11 UTC, Guillaume Poirier-Morency
Details

Description Guillaume Poirier-Morency 2016-02-20 18:34:20 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.
Comment 1 Guillaume Poirier-Morency 2016-02-20 19:11:58 UTC
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'.
Comment 2 Guillaume Poirier-Morency 2016-02-20 20:31:28 UTC
Just to add: all Vala implementations of FilterInputStream and FilterOutputStream are inexorably broken: they will suffer from the 'write_all' loop.
Comment 3 GNOME Infrastructure Team 2018-05-22 15:31:25 UTC
-- 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.