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 702832 - No warning for methods declaring throws that do not throw
No warning for methods declaring throws that do not throw
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Errors
0.18.x
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-06-21 19:02 UTC by Richard Schwarting
Modified: 2018-05-22 14:50 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Richard Schwarting 2013-06-21 19:02:28 UTC
Currently, if a method is declared as throwing an error, and a caller doesn't catch it, there's a warning.

However, if a method is declared as throwing an error, and never does throw an error, there's no warning.  

For larger code bases, gradual changes in error handling can be hard to keep track of, and it would be nice to know if something should be throwing an error, but is not.

STEPS TO REPRODUCE
1. Compile the following code: 

public errordomain SomeError {
    FISH;
}
public static void go_fish () throws SomeError {
}
public static void main () {
    go_fish ();
}

ACTUAL RESULTS:
No warning that go_fish () doesn't actually throw an error.

EXPECTED RESULTS:
A warning if go_fish never throws an error (and does not call a method that would, either).
Comment 1 Luca Bruno 2013-06-22 06:36:10 UTC
Good idea, patches accepted.
Comment 2 Maciej (Matthew) Piechotka 2013-06-23 16:11:07 UTC
Given that the declaration changes both API and ABI there should be an easy way to suppress warnings. A library which removed the possibility of throwing error in method might still want to declare it to maintain the backward compatibility.
Comment 3 Jürg Billeter 2013-06-24 14:35:07 UTC
In addition to what Maciej wrote, it's also possible that you write a method that might throw an error in a future version and you already specify 'throws' to avoid breaking the interface later on.

For these reasons, there should be no such warning by default. We should only warn if something is wrong, at least by default.
Comment 4 GNOME Infrastructure Team 2018-05-22 14:50:46 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/387.