mfichman / jogo

High(er) performance compiled programming language with clean, powerful syntax
MIT License
6 stars 1 forks source link

Generics type checking issue when 1st statement in loop #76

Closed mfichman closed 10 years ago

mfichman commented 11 years ago

The following code works:

read(key :k, chan Chan[:a]) {
    # Reads from the output channel until empty.
    for item in chan {
        out.put(Pair[:k,:a](key, item)) 
    }
}

But this doesn't:

read(key :k, chan Chan[:a]) {
    # Reads from the output channel until empty.
    for item in chan {
        if out.state == ChanState::CLOSED {
            ret
        }
        out.put(Pair[:k,:a](key, item)) 
    }
}

The error message is:

Chan.jg:36:28: Unbound generic type ':k'
Chan.jg:36:21: Argument does not conform to type 'Pair[:k,:a]' (:a)

It seems like the 1st statement in the loop is not typechecked.