gc_malloc unresolved #840

Closed
zhaihj opened this Issue Oct 10, 2014 · 5 comments

Projects

None yet

3 participants

@zhaihj
Contributor
zhaihj commented Oct 10, 2014
tfoo: class<T>{
    init: func(){}
    a: T
    b: T{
        get { a }
        set(c){ a = c }
    }
}

tbar := tfoo<Int> new()

the above code generates errors:

[lang/Backtrace] Falling back on execinfo.. (build extension if you want fancy backtraces)
[Exception in FunctionCallWriter]: Trying to write unresolved function gc_malloc(T size)

(SIGABRT) abort program
[lang/Backtrace] Falling back on execinfo.. (build extension if you want fancy backtraces)
./rock_pure/bin/rock(lang_Backtrace__BacktraceHandler_backtrace_impl+0x115) [0x55ec85]
./rock_pure/bin/rock(lang_Exception__Exception_getCurrentBacktrace+0x13) [0x54c443]
./rock_pure/bin/rock(lang_Exception___signalHandler+0x124) [0x54c594]
/usr/lib/libc.so.6(+0x339f0) [0x7fbf0d7239f0]
/usr/lib/libc.so.6(gsignal+0x37) [0x7fbf0d723967]
/usr/lib/libc.so.6(abort+0x16a) [0x7fbf0d724d3a]
./rock_pure/bin/rock(lang_Exception__Exception_throw_impl+0x43) [0x54d823]
./rock_pure/bin/rock(rock_backend_cnaughty_FunctionCallWriter__FunctionCallWriter_write_functionCall+0x9c1) [0x51c5a1]

but this works

tfoo: class<T>{
    init: func(){}
    a: T

tbar := tfoo<Int> new()
@shamanas shamanas self-assigned this Oct 10, 2014
@shamanas
Collaborator

That's weird, I'll be on it.

@fasterthanlime
Collaborator

Tbh, the fact that properties sometimes don't properly resolve what's inside of them is not a big surprise. Ever since PDFE syntax they've been kind of fragile..

@shamanas
Collaborator

This is probably a problem because 'a = c' is replaced in the property declaration (or perhaps even 'a'), as a and c are of generic type.

@zhaihj
Contributor
zhaihj commented Jan 14, 2015

It seems that properties are not properly implemented for generic class.
In normal class, it will geterate get_ and set_ function. But in generics, b: Int { get {a }} will be accessed just like a class member ( in my case, in defaults).

@zhaihj
Contributor
zhaihj commented Jan 14, 2015

ok, finally get it.
VariableDecl generates expr for properties. This has been fixed.
But here comes another problem, accessing tbar a will return a reference of a(because it is a generic) instead of a itself.
Relate issue(almost the same reason): #804

@fasterthanlime fasterthanlime modified the milestone: 0.9.10 Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment