ammarbinfaisal / sahl

a programming language with channels and coroutines/threads
MIT License
9 stars 1 forks source link

chanrecv blocked while it shouldn't be #58

Open ammarbinfaisal opened 1 year ago

ammarbinfaisal commented 1 year ago

the code below gets stuck at 999 each time

fun sendvals(c: chan<int>, count: int) {
    let i = 0
    while i < count {
        c <- i
        i = i + 1
    }
}

fun main() {
    let i = 0
    while i < 100 {
        let count = 1000
        let a = make(chan<int>, count)
        sahl sendvals(a, count)
        let j = 0
        while j < count {
            print(<-a, "\n")
            j = i + 1
        }
        i = i + 1
    }
}
mayankpatel-mit commented 9 months ago

try j = j + 1 instead of j = i + 1

ammarbinfaisal commented 9 months ago

I see what the error in the example was but I still remains blocked. Something's wrong with how channels are implemented in the vm.