scripts/globals: add check_var function (check_decl but for variables).