The following code is a simplification of a code of a library I'm working on. The code runs but it does not produces the expected output. The problem turns out to be the use of a wrong variable name (k instead of c) in the function fn. However, no error was not reported.
fn(ch, c) = put!(ch, k)
chnl = Channel{Char}(1)
function producer(ch,str)
for c in str
fn(ch, c)
end
end
consumer(ch) = for c in ch
print(c)
end
Threads.@spawn producer(chnl, "Hello World!\n")
Threads.@spawn consumer(chnl)
sleep(1)
println("Done")
Detecting this problem took me a while on the original code, because no error was reported. Is there something I could use to detect this type of problem in the future, specially because function fn is suppose to be written by the user?