GNOME Bugzilla – Bug 606783
async functions fail to compile when there are variables with the same in different scopes
Last modified: 2010-01-14 22:02:07 UTC
In a normal function(non async) you can have: def some_function() try some_operation() except e: FileError print e.message except e: Error print e.message And it will work because each error variable is in a different scope. However, the same code fails when the function is asynchronous, because the local variables are stored in a structure instead of being local variables. In the case refered above, vala fails with: valac -C test.gs test.c: error: duplicate member ‘e’
// Example code void some_operation() throws FileError, Error { } async void some_function() { try { some_operation(); } catch(FileError e) { print(e.message); } catch(Error e) { print(e.message); } } void main() { some_function(); }
Structure generated in the C code. struct _SomeFunctionData { int _state_; GAsyncResult* _res_; GSimpleAsyncResult* _async_result; GError * e; GError * e; GError * _inner_error_; };
Created attachment 151313 [details] test-case-async.vala Code for the test case referred above
This has already been reported (several times actually). See bug 596861.
Already reported. *** This bug has been marked as a duplicate of bug 596861 ***