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

Closed
nddrylliog opened this issue Jun 7, 2012 · 2 comments
Closed
Labels

Comments

@nddrylliog
Copy link
Member

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() {
    GC_INIT();
    no_getter_load();
    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.

@alexnask
Copy link
Collaborator

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));
lang_string__String_println(T->name);

@fasterthanlime
Copy link
Collaborator

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants