Detecting and preventing type flaws at static time