Variables should be validated before execution starts, ideally even as part of a cached document (i.e. so that the same document is only validated once). Currently, this is done in Variables.kt during retrieval, even when e.g. invalid type declarations could easily be validated statically.