Skip to content

Commit ee812fc

Browse files
committed
only warn about Vararg wrapping once
This quiets down the long message in #38136 to be once-per-process when running with `--depwarn=yes` instead of spamming log files continually. We probably should have considered doing this a long time ago, but hopefully better now than never.
1 parent 48bd673 commit ee812fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/jltypes.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,9 @@ JL_DLLEXPORT jl_value_t *jl_type_unionall(jl_tvar_t *v, jl_value_t *body)
910910
if (jl_options.depwarn) {
911911
if (jl_options.depwarn == JL_OPTIONS_DEPWARN_ERROR)
912912
jl_error("Wrapping `Vararg` directly in UnionAll is deprecated (wrap the tuple instead).\nYou may need to write `f(x::Vararg{T})` rather than `f(x::Vararg{<:T})` or `f(x::Vararg{T}) where T` instead of `f(x::Vararg{T} where T)`.");
913-
jl_printf(JL_STDERR, "WARNING: Wrapping `Vararg` directly in UnionAll is deprecated (wrap the tuple instead).\nYou may need to write `f(x::Vararg{T})` rather than `f(x::Vararg{<:T})` or `f(x::Vararg{T}) where T` instead of `f(x::Vararg{T} where T)`.\nTo make this warning an error, and hence obtain a stack trace, use `julia --depwarn=error`.\n");
913+
static _Atomic(int) warnedonce;
914+
if (jl_atomic_load_relaxed(&warnedonce) == 0 && jl_atomic_exchange_relaxed(&warnedonce, 1) == 0)
915+
jl_printf(JL_STDERR, "WARNING: Wrapping `Vararg` directly in UnionAll is deprecated (wrap the tuple instead).\nYou may need to write `f(x::Vararg{T})` rather than `f(x::Vararg{<:T})` or `f(x::Vararg{T}) where T` instead of `f(x::Vararg{T} where T)`.\nTo make this warning an error, and hence obtain a stack trace, use `julia --depwarn=error`.\n");
914916
}
915917
jl_vararg_t *vm = (jl_vararg_t*)body;
916918
int T_has_tv = vm->T && jl_has_typevar(vm->T, v);

0 commit comments

Comments
 (0)