Skip to content

Failure when trying to pass bracket operator as argument to a callback function in generic class #69

@ghost

Description

I'm bad at naming threads.

Foo: class <T> {
    _t: T
    init: func (=_t)
    bar: func (callback: Func (T*) -> Bool) {
        if (callback(this[0]&)) {
        } else {
        }
    }
    operator[] (index: Int) -> T {
        _t
    }
}

magic-lang rock compiler 1.0.20
file.ooc: In function ‘file__Foo_bar’:
file.ooc:6:5: error: ‘else’ without a previous ‘if’
} else {
^

Workaround (@marcusnaslund ) :

Foo: class <T> {
    _t: T
    init: func (=_t)
    bar: func (callback: Func (T*) -> Bool) {
        ok: Bool
        ok = callback(this[0]&)
        if (ok) {
        } else {
        }
    }
    operator[] (index: Int) -> T {
        _t
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions