1. A non-transitory, computer-readable storage medium storing program instructions that when executed on a computing device cause the computing device to implement: parsing, by a compiler, source code written in a dynamically typed language; determining, by the compiler, an element of the source code that has a unspecified type, wherein the element results from an operation in the source code, wherein the element has a type unspecified to the compiler; and in response to said determining, generating, by the compiler using a first type assumption that treats the element as a first candidate type, first candidate compiled code which upon execution by an execution engine is configured to: detect, during execution of the first candidate compiled code, that the first type assumption is invalid for the first candidate compiled code; in response to detecting that the first type assumption is invalid: replace at least a portion of the first candidate compiled code with second candidate compiled code that treats the element as a second candidate type according to a second type assumption; and execute the second candidate compiled code such that execution continues from an execution point in the second candidate compiled code that matches an execution point in the first candidate compiled code at which the invalidity of the first type assumption was detected.