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

gc_malloc unresolved #840

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

Comments

@zhaihj
Copy link
Contributor

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()

@alexnask alexnask self-assigned this Oct 10, 2014

@alexnask

This comment has been minimized.

Copy link
Collaborator

commented Oct 10, 2014

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

@fasterthanlime

This comment has been minimized.

Copy link
Collaborator

commented Oct 10, 2014

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..

@alexnask

This comment has been minimized.

Copy link
Collaborator

commented Oct 12, 2014

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor Author

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

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