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 587905 - Generic type parameter inside non-generic nested class triggers assertion instead of proper error
Generic type parameter inside non-generic nested class triggers assertion ins...
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Generics
unspecified
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
: 635983 737500 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-07-06 17:19 UTC by zarevucky.jiri
Modified: 2018-02-17 15:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vala: Report error for missing type-parameter on enclosing type (2.06 KB, patch)
2017-11-19 15:34 UTC, Rico Tzschichholz
committed Details | Review

Description zarevucky.jiri 2009-07-06 17:19:38 UTC
Example:

class Generic<T> {

    class Nested {
        public T member;
    }

}

Results in:

ERROR:valasemanticanalyzer.c:2934:vala_semantic_analyzer_get_actual_type: assertion failed: (instance_type != NULL)
Comment 1 Michael 'Mickey' Lauer 2009-10-14 23:43:26 UTC
Confirmed, although this code is invalid. Inner classes in generics are considered static. Vala needs to emit an error though instead of creating invalid code. post-0.7.7 Vala emits:

/tmp/foo.vala.c:238: error: dereferencing pointer to incomplete type

if the offending member is public, and

/tmp/foo.vala.c: In function 'generic_nested_finalize':
/tmp/foo.vala.c:244: error: 'GenericNestedPrivate' has no member named 't_destroy_func'

if it is private.
Comment 2 Florian Brosch 2013-05-11 14:10:10 UTC
*** Bug 635983 has been marked as a duplicate of this bug. ***
Comment 3 grindhold 2017-11-03 21:49:53 UTC
i don't know wheter this is too obvious, but a workaround is passing the template down to the inner class like this:

class Generic<T> {

    class Nested<T> {
        public T member;
    }

}
Comment 4 Rico Tzschichholz 2017-11-19 15:34:51 UTC
Created attachment 364008 [details] [review]
vala: Report error for missing type-parameter on enclosing type

Make a qualified guess for the cause of the problem instead of triggering
an assertion.
Comment 5 Rico Tzschichholz 2017-11-19 15:53:12 UTC
Attachment 364008 [details] pushed as 6b656b0 - vala: Report error for missing type-parameter on enclosing type
Comment 6 Rico Tzschichholz 2018-02-17 15:40:04 UTC
*** Bug 737500 has been marked as a duplicate of this bug. ***