AdeptLanguage / Adept

The Adept Programming Language
GNU General Public License v3.0
124 stars 9 forks source link

[unimplemented] Allow for variadic methods when using new variadic argument scheme #20

Closed IsaacShelton closed 4 years ago

IsaacShelton commented 4 years ago

import VariadicArray
import 'sys/cstdio.adept'

struct Dummy ()

func main {
    dummy Dummy
    printf('sum = %d\n', dummy.sumEmUp(1, 2, 3, 4, 5))
}

func sumEmUp(this *Dummy, integers ...) int {
    printf('%p\n', integers.items)
    printf('%p\n', integers.next)
    printf('%d\n', integers.length as int)
    printf('%d\n', integers.index as int)
    printf('%p\n', integers.types)

    sum int = 0
    while integers.hasNext() {
        if integers.types[integers.index] != typeinfo int {
            printf('ERROR: sumEmUp() got non-int value!\n')
            return 0
        }

        x int = integers.readInt()
        printf('Got value: %d\n', x)
        sum += x
    }
    return sum
}

Arguments are not being packaged into a VariadicArray before being passed

IsaacShelton commented 4 years ago

Fixed in commit 99f131c0d8c94682161310439d34eff498df181a