Open marcusnaslund opened 8 years ago
I'm taking a look at this right now (I'm assuming myCovers is an ArrayList of some cover) but what was said in the ooc-kean issue looks accurate.
It looks like we could generate some code that would handle it, I will reopen the issue if we indeed can.
Let me take a closer look and get back to you on this.
I can reproduce this with an ooc array:
import structs/ArrayList
Foo: cover {
calculated ::= 42
}
arr := Foo[1] new()
foo: Foo
arr[0] = foo
arr[0] calculated toString() println()
Using an ArrayList seems to work on my end.
If you could post a testcase I would be grateful.
@marcusnaslund , just a reminder...
import structs/ArrayList
Foos: class {
init: func
operator [] (index: Int) -> Foo {
Foo new()
}
}
Foo: cover {
bar: Int
init: func@
}
foos := Foos new()
list := ArrayList<Int> new()
list add(foos[0] bar)
This fails to build with the error
lvalue required as unary ‘&’ operand
list add(foos[0] bar)
However, any of the 3 following changes will independently fix the build error:
foo := foos[0]
list add(foo bar)
bar
into a property bar: Int { get set }
Foo
a class instead of a cover:Foo: class {
bar: Int
init: func
}
I don't know if this is specifically what @marcusnaslund had a problem with, but perhaps it's related?
Oh, thank you very much @davidhesselbom - then we are able to reproduce this issue both with arrays and ArrayList
. I'm reponening this.
For example:
It appears properties have similar limitations in C# as well, so I don't know what the plan is here.
At least, the error should be explained by rock instead of failing in the C compiler.