Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing generic member variables produces invalid (read: uncasted) code #425

nddrylliog opened this issue Jun 7, 2012 · 2 comments


Copy link

commented Jun 7, 2012

The following ooc code:

Jar: class <Z> {
    cookie: Z

    init: func (=cookie)

#specialize Jar<Int>

main: func {
    j := Jar<Int> new(42 as Int) 
    printf("j's cookie = %d\n", j cookie)

    k := Jar new("Folks")
    printf("k's cookie = %s\n", k cookie)

Produces stuff like that for the main func:

lang_Numbers__Int main() {
    no_getter__Jar___specialized1* j = no_getter__Jar___specialized1_new(((lang_Numbers__Int) (42)));
    lang_IO__printf(lang_string____OP_AS_String__Char__star(__strLit2), j->cookie);
    no_getter__Jar* k = no_getter__Jar_new((lang_core__Class*)lang_string__String_class(), (uint8_t*) &(__strLit3));
    lang_IO__printf(lang_string____OP_AS_String__Char__star(__strLit4), k->cookie);
    return ((lang_Numbers__Int) (0));

Which is obviously very wrong, the second printf should be:

    lang_IO__printf(lang_string____OP_AS_String__Char__star(__strLit4), *((char**) k->cookie));

Well, with the additional rock-ish underscore orgy, but you get the idea.


This comment has been minimized.

Copy link

commented Jul 18, 2012

Here are two other related (kinda) bugs:

cell := Cell new(42)
fourtytwo := cell val // ERROR Undefined symbol 'T'
cell := Cell new(42)
cell val class name println()

This generates the following C code:

test__cell = lang_core__Cell_new((lang_core__Class*)lang_Numbers__SSizeT_class(), (uint8_t*) &(__genArg107));

This comment has been minimized.

Copy link

commented Jul 10, 2015

Ah, there we go. That was fixed as #889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.