magic-lang / rock

ooc compiler written in ooc
http://ooc-lang.org/
MIT License
14 stars 4 forks source link

Adding enum elements to a List #67

Closed naslundx closed 7 years ago

naslundx commented 8 years ago

The following code fails

use math

list := IntVectorList new()
list add(Owner Receiver as Int)
list[0] toString() println()

with error: lvalue required as unary ‘&’ operand.

The following code works

use math

list := IntVectorList new()
list add(_ := Owner Receiver as Int)
list[0] toString() println()

clearly, the values from the enum have to be assigned to something before added to a list. I think rock should be able to figure this out automatically.

I can't atm test if the same is true of ArrayList and ooc-lang/rock (hence the issue here) but I would guess so.

marcusnaslund commented 8 years ago

Accidentally used the wrong github account. Ah well.

alexnask commented 8 years ago

This looks like it could have been fixed by #45, checking...

EDIT: Actually the following code works with rock without that fix and I'm having a bit of trouble with ooc-kean right now, wil test a bit later.

import structs/ArrayList

Test: enum {
    A
    B
}

al := ArrayList<Int> new()

al add(Test A as Int)
al[0] toString() println()
thomasfanell commented 7 years ago

This appears to be fixed now. Closing

marcusnaslund commented 7 years ago

Awesome. :+1: