Skip to content

Commit

Permalink
Use invokelatest after eval to adjust to upcoming julia change
Browse files Browse the repository at this point in the history
In 1.12, we're cleaning up when implicit world age increments happen
at toplevel. Because these test `eval` an expression and immediately
call it, an `invokelatest` will likely be required (as it would be
right now in local scope). See JuliaLang/julia#56509
  • Loading branch information
Keno committed Nov 20, 2024
1 parent 40c4008 commit bbe5372
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ end
anon = :((t, x) -> f(t, x, 1, d = 1))
@test InfiniteOpt._process_func_expr(error, anon) == (esc(anon), esc(:(t,x)), true)
anon = :((t, x[1]) -> sin(t + x[1]))
@test eval(InfiniteOpt._process_func_expr(error, anon)[1].args[1])(0.5, 0.2) == sin(0.5 + 0.2)
@test invokelatest(eval(InfiniteOpt._process_func_expr(error, anon)[1].args[1]), 0.5, 0.2) == sin(0.5 + 0.2)
anon = :(t[i] -> t[i] + 3)
@test eval(InfiniteOpt._process_func_expr(error, anon)[1].args[1])(2) == 5
# test errors
@test invokelatest(eval(InfiniteOpt._process_func_expr(error, anon)[1].args[1]), 2) == 5
# test errors
@test_throws ErrorException InfiniteOpt._process_func_expr(error, :(f(t, d = 2)))
@test_throws ErrorException InfiniteOpt._process_func_expr(error, :(f(x, t; d = 2)))
@test_throws ErrorException InfiniteOpt._process_func_expr(error, :(f >= 2))
Expand Down

0 comments on commit bbe5372

Please sign in to comment.