Skip to content

Commit 2f2b0f0

Browse files
committed
Make warned_warn_about_threads_threads_threads_threads shorter
1 parent d013e61 commit 2f2b0f0

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

src/compiler.jl

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -346,19 +346,19 @@ Generate the body of the main evaluation function from expression `expr` and arg
346346
If `warn` is true, a warning is displayed if internal variables are used in the model
347347
definition.
348348
"""
349-
generate_mainbody(mod, expr, warn, warned_about_threads_threads) =
350-
generate_mainbody!(mod, Symbol[], expr, warn, warned_about_threads_threads)
349+
generate_mainbody(mod, expr, warn, warn_threads) =
350+
generate_mainbody!(mod, Symbol[], expr, warn, warn_threads)
351351

352-
generate_mainbody!(mod, found, x, warn, warned_about_threads_threads) = x
353-
function generate_mainbody!(mod, found, sym::Symbol, warn, warned_about_threads_threads)
352+
generate_mainbody!(mod, found, x, warn, warn_threads) = x
353+
function generate_mainbody!(mod, found, sym::Symbol, warn, warn_threads)
354354
if warn && sym in INTERNALNAMES && sym found
355355
@warn "you are using the internal variable `$sym`"
356356
push!(found, sym)
357357
end
358358

359359
return sym
360360
end
361-
function generate_mainbody!(mod, found, expr::Expr, warn, warned_about_threads_threads)
361+
function generate_mainbody!(mod, found, expr::Expr, warn, warn_threads)
362362
# Do not touch interpolated expressions
363363
expr.head === :$ && return expr.args[1]
364364

@@ -369,15 +369,14 @@ function generate_mainbody!(mod, found, expr::Expr, warn, warned_about_threads_t
369369

370370
# Do we don't want escaped expressions because we unfortunately
371371
# escape the entire body afterwards.
372-
Meta.isexpr(expr, :escape) && return generate_mainbody(
373-
mod, found, expr.args[1], warn, warned_about_threads_threads
374-
)
372+
Meta.isexpr(expr, :escape) &&
373+
return generate_mainbody(mod, found, expr.args[1], warn, warn_threads)
375374

376375
# If it's a macro, we expand it
377376
if Meta.isexpr(expr, :macrocall)
378377
if expr.args[1] == Expr(:., :Threads, QuoteNode(Symbol("@threads"))) &&
379-
!warned_about_threads_threads
380-
warned_about_threads_threads = true
378+
!warn_threads
379+
warn_threads = true
381380
@warn (
382381
"It looks like you are using `Threads.@threads` in your model definition." *
383382
"\n\nNote that since version 0.39 of DynamicPPL, threadsafe evaluation of models is disabled by default." *
@@ -386,11 +385,7 @@ function generate_mainbody!(mod, found, expr::Expr, warn, warned_about_threads_t
386385
)
387386
end
388387
return generate_mainbody!(
389-
mod,
390-
found,
391-
macroexpand(mod, expr; recursive=true),
392-
warn,
393-
warned_about_threads_threads,
388+
mod, found, macroexpand(mod, expr; recursive=true), warn, warn_threads
394389
)
395390
end
396391

@@ -399,11 +394,7 @@ function generate_mainbody!(mod, found, expr::Expr, warn, warned_about_threads_t
399394
if args_dottilde !== nothing
400395
L, R = args_dottilde
401396
return generate_mainbody!(
402-
mod,
403-
found,
404-
Base.remove_linenums!(generate_dot_tilde(L, R)),
405-
warn,
406-
warned_about_threads_threads,
397+
mod, found, Base.remove_linenums!(generate_dot_tilde(L, R)), warn, warn_threads
407398
)
408399
end
409400

@@ -413,8 +404,8 @@ function generate_mainbody!(mod, found, expr::Expr, warn, warned_about_threads_t
413404
L, R = args_tilde
414405
return Base.remove_linenums!(
415406
generate_tilde(
416-
generate_mainbody!(mod, found, L, warn, warned_about_threads_threads),
417-
generate_mainbody!(mod, found, R, warn, warned_about_threads_threads),
407+
generate_mainbody!(mod, found, L, warn, warn_threads),
408+
generate_mainbody!(mod, found, R, warn, warn_threads),
418409
),
419410
)
420411
end
@@ -425,18 +416,15 @@ function generate_mainbody!(mod, found, expr::Expr, warn, warned_about_threads_t
425416
L, R = args_assign
426417
return Base.remove_linenums!(
427418
generate_assign(
428-
generate_mainbody!(mod, found, L, warn, warned_about_threads_threads),
429-
generate_mainbody!(mod, found, R, warn, warned_about_threads_threads),
419+
generate_mainbody!(mod, found, L, warn, warn_threads),
420+
generate_mainbody!(mod, found, R, warn, warn_threads),
430421
),
431422
)
432423
end
433424

434425
return Expr(
435426
expr.head,
436-
map(
437-
x -> generate_mainbody!(mod, found, x, warn, warned_about_threads_threads),
438-
expr.args,
439-
)...,
427+
map(x -> generate_mainbody!(mod, found, x, warn, warn_threads), expr.args)...,
440428
)
441429
end
442430

0 commit comments

Comments
 (0)