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
horasal opened this issue Oct 10, 2014 · 5 comments
Closed

gc_malloc unresolved #840

horasal opened this issue Oct 10, 2014 · 5 comments
Assignees
Milestone

Comments

@horasal
Copy link
Contributor

@horasal horasal 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
Copy link
Collaborator

@alexnask alexnask commented Oct 10, 2014

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

Loading

@fasterthanlime
Copy link
Collaborator

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

Loading

@alexnask
Copy link
Collaborator

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

Loading

@horasal
Copy link
Contributor Author

@horasal horasal 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).

Loading

@horasal
Copy link
Contributor Author

@horasal horasal 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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants