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 606783 - async functions fail to compile when there are variables with the same in different scopes
async functions fail to compile when there are variables with the same in dif...
Status: RESOLVED DUPLICATE of bug 596861
Product: vala
Classification: Core
Component: Async
0.7.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-01-12 21:26 UTC by Sandino Flores-Moreno
Modified: 2010-01-14 22:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test-case-async.vala (238 bytes, application/octet-stream)
2010-01-13 05:42 UTC, Sandino Flores-Moreno
Details

Description Sandino Flores-Moreno 2010-01-12 21:26:04 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’
Comment 1 Sandino Flores-Moreno 2010-01-13 05:37:09 UTC
// 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();
}
Comment 2 Sandino Flores-Moreno 2010-01-13 05:38:42 UTC
Structure generated in the C code.

struct _SomeFunctionData {
        int _state_;
        GAsyncResult* _res_;
        GSimpleAsyncResult* _async_result;
        GError * e;
        GError * e;
        GError * _inner_error_;
};
Comment 3 Sandino Flores-Moreno 2010-01-13 05:42:35 UTC
Created attachment 151313 [details]
test-case-async.vala

Code for the test case referred above
Comment 4 zarevucky.jiri 2010-01-13 08:48:58 UTC
This has already been reported (several times actually). See bug 596861.
Comment 5 Sandino Flores-Moreno 2010-01-14 22:02:07 UTC
Already reported.

*** This bug has been marked as a duplicate of bug 596861 ***