Skip to content

Commit

Permalink
Improve error when generated function is not pure (JuliaLang#39568)
Browse files Browse the repository at this point in the history
I hadn't realized that this included generators so it could help others.
  • Loading branch information
nalimilan committed Feb 9, 2021
1 parent 78c448f commit df7334a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/method.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo)
ptls->in_pure_callback = 0;
jl_toplevel_eval(def->module, (jl_value_t*)func);
}
jl_error("The function body AST defined by this @generated function is not pure. This likely means it contains a closure or comprehension.");
jl_error("The function body AST defined by this @generated function is not pure. This likely means it contains a closure, a comprehension or a generator.");
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5000,7 +5000,8 @@ gVararg(a::fVararg(Int)) = length(a)
false
catch e
(e::ErrorException).msg
end == "The function body AST defined by this @generated function is not pure. This likely means it contains a closure or comprehension."
end == "The function body AST defined by this @generated function is not pure. " *
"This likely means it contains a closure, a comprehension or a generator."

let x = 1
global g18444
Expand Down

0 comments on commit df7334a

Please sign in to comment.