Skip to content

Commit 3377418

Browse files
committed
@with_context: Escape arguments
1 parent 21c82b3 commit 3377418

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/context.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ See also [`with_context`](@ref).
7272
"""
7373
macro with_context(params, expr)
7474
return quote
75-
@with Decimals.CONTEXT => Decimals.Context(;$params...) $(esc(expr))
75+
@with Decimals.CONTEXT => Decimals.Context(;$(esc(params))...) $(esc(expr))
7676
end
7777
end
7878

test/test_context.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ using Decimals: @with_context, with_context
66
@testset "Context" begin
77
@testset "precision" begin
88
@test precision(Decimal) == 28
9-
with_context(precision=42) do
10-
@test precision(Decimal) == 42
9+
prec = 42
10+
with_context(precision=prec) do
11+
@test precision(Decimal) == prec
1112
end
12-
@with_context (precision=42,) @test precision(Decimal) == 42
13+
@with_context (precision=prec,) @test precision(Decimal) == prec
1314
end
1415

1516
@testset "rounding" begin

0 commit comments

Comments
 (0)