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 575628 - Check expression type of constant initializers
Check expression type of constant initializers
Status: RESOLVED DUPLICATE of bug 587947
Product: vala
Classification: Core
Component: Semantic Analyzer
0.5.x
Other All
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
: 585292 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-03-17 00:27 UTC by Michael 'Mickey' Lauer
Modified: 2009-09-17 15:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael 'Mickey' Lauer 2009-03-17 00:27:59 UTC
Please describe the problem:
The following legal vala code leads to illegal c code:

using GLib;

const KeyFile keyfile = new KeyFile();

public static int main( string[] args )
{
    var context = new MainContext();
    return 0;
}


Steps to reproduce:
gint _main (char** args, int args_length1) {
        GKeyFile* _tmp0;
        GMainContext* _tmp0;
        GMainContext* context;
        gint _tmp1;
        _tmp0 = NULL;
        _tmp0 = NULL;
        context = (_tmp0 = g_main_context_new (), (_tmp0 == NULL) ? NULL : (_tmp0 = (g_key_file_free (_tmp0), NULL)), _tmp0);
        return (_tmp1 = 0, (context == NULL) ? NULL : (context = (g_main_context_unref (context), NULL)), _tmp1);
}


int main (int argc, char ** argv) {
        g_type_init ();
        return _main (argv, argc);
}


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Jürg Billeter 2009-03-26 19:29:31 UTC
As object creation expressions are not constant expressions, they are not supported as initializer for constants. Your example is incorrect, the semantic analyzer just fails to detect the error.
Comment 2 Jürg Billeter 2009-06-26 06:27:49 UTC
*** Bug 585292 has been marked as a duplicate of this bug. ***
Comment 3 Jürg Billeter 2009-09-17 15:40:25 UTC
Thanks for taking the time to report this bug.
This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed. It should be solved in the next software version. You may want to check for a software upgrade.

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