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 614294 - Mismatching error signature in async virtual function leads to invalid C code
Mismatching error signature in async virtual function leads to invalid C code
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Async
0.26.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-29 20:45 UTC by Michael 'Mickey' Lauer
Modified: 2018-02-04 10:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
codegen: Method needs to throw error if their base method does (2.19 KB, patch)
2018-01-27 12:47 UTC, Rico Tzschichholz
rejected Details | Review
codegen: Infer error parameter from abstract/virtual method implementations (4.31 KB, patch)
2018-01-27 15:57 UTC, Rico Tzschichholz
committed Details | Review

Description Michael 'Mickey' Lauer 2010-03-29 20:45:54 UTC
Please consider the following test case:
=======================================

public enum UsageResourcePolicy
{
        FOO,
        BAR
}

public errordomain MyError
{
        FOO,
        BAR
}

public interface IResource : Object
{
        public abstract async void setPolicy( UsageResourcePolicy policy ) throws MyError, DBus.Error;
}

public class Resource : IResource, Object
{
        public virtual async void setPolicy( UsageResourcePolicy policy )
        {
                message( "yo" );
        }
}

async void runAsync()
{
        var r = new Resource();
        yield r.setPolicy( UsageResourcePolicy.FOO );
}

void main()
{
        runAsync();
}

=======================================
mickey@andromeda:/tmp$ valac --save-temps --pkg gio-2.0 --pkg dbus-glib-1 async.vala
/tmp/async.c: In function ‘resource_iresource_interface_init’:
/tmp/async.c:243: warning: assignment from incompatible pointer type
/tmp/async.c:244: warning: assignment from incompatible pointer type
/tmp/async.c: In function ‘runAsync_co’:
/tmp/async.c:312: error: too few arguments to function ‘resource_setPolicy_finish’
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Comment 1 Michael 'Mickey' Lauer 2010-03-29 20:46:17 UTC
Vala should probably refuse to compile this and emit an error.
Comment 2 Frederik Sdun 2010-09-14 07:31:36 UTC
It seems that the error parameter is missing in the code.
why should vala refuse to compile this code?
Comment 3 Michael 'Mickey' Lauer 2015-02-03 13:01:49 UTC
Because Vala should try very hard to never emit C code that doesn't compile.

It's breaking the semantic level of abstraction, if you force the user finding out what's wrong in the C code to fix it in Vala code.
Comment 4 Luca Bruno 2015-02-03 13:08:25 UTC
In this case vala should be smarter. Frmo a semantic view point, it's fine to have no throws in the overridden method as it's stronger. In this case the C code should still emit the error parameter, and set it to NULL.
Comment 5 Rico Tzschichholz 2018-01-27 12:47:20 UTC
Created attachment 367514 [details] [review]
codegen: Method needs to throw error if their base method does
Comment 6 Rico Tzschichholz 2018-01-27 14:17:03 UTC
Making this fatal causes more fuzz than I expected, so going to infer error-types from base-method would be smarter.

http://paldo.org:8010/builders/vala-staging/builds/394
Comment 7 Rico Tzschichholz 2018-01-27 15:57:55 UTC
Created attachment 367523 [details] [review]
codegen: Infer error parameter from abstract/virtual method implementations
Comment 8 Rico Tzschichholz 2018-01-27 16:31:54 UTC
Attachment 367523 [details] pushed as 527dac8 - codegen: Infer error parameter from abstract/virtual method implementations