Is the compiler able to give warnings that an iterator's internal state modified?

29 views
Skip to first unread message

FANG Colin

unread,
Nov 18, 2016, 1:26:05 PM11/18/16
to julia-users
I guess the following is buggy code

   dict = Dict(x=>x for x in 1:100);
    for x in keys(dict)
            delete!(dict, x)
    end


As we need to `collect(keys(...))` to make a copy.

However the code above still runs with correct results. Even when it fails to return correct results, no error would be thrown. 

Just wondering in the language design point of view if the compiler or runtime can detect this sort of behaviour always?
Reply all
Reply to author
Forward
0 new messages