Skip to content

Commit 05cbc3c

Browse files
committed
Use pushfirst! to change precedence
1 parent 6f6115c commit 05cbc3c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/systems/abstractsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ function _named(expr)
455455
kws = call.args[2].args
456456

457457
if !any(kw->(kw isa Symbol ? kw : kw.args[1]) == :name, kws) # don't overwrite `name` kwarg
458-
push!(kws, Expr(:kw, :name, Meta.quot(name)))
458+
pushfirst!(kws, Expr(:kw, :name, Meta.quot(name)))
459459
end
460460
:($name = $call)
461461
end

test/direct.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ pp = :name => :cool_name
215215

216216
@named cool_name = foo(42; a = 2)
217217
@test cool_name[1] == (42,)
218-
@test collect(cool_name[2]) == [:a => 2; pp]
218+
@test collect(cool_name[2]) == [pp; :a => 2]
219219

220220
@named cool_name = foo(a = 2)
221-
@test collect(cool_name) == [:a => 2; pp]
221+
@test collect(cool_name) == [pp; :a => 2]
222222

223223
@named cool_name = foo(;a = 2)
224-
@test collect(cool_name) == [:a => 2; pp]
224+
@test collect(cool_name) == [pp; :a => 2]
225225

226226
@named cool_name = foo(name = 2)
227227
@test collect(cool_name) == [:name => 2]
@@ -230,6 +230,11 @@ pp = :name => :cool_name
230230
@test cool_name[1] == (42,)
231231
@test collect(cool_name[2]) == [:name => 3]
232232

233+
kwargs = (;name = 3)
234+
@named cool_name = foo(42; kwargs...)
235+
@test cool_name[1] == (42,)
236+
@test collect(cool_name[2]) == [:name => 3]
237+
233238
if VERSION >= v"1.5"
234239
name = 3
235240
@named cool_name = foo(42; name)
@@ -241,8 +246,8 @@ if VERSION >= v"1.5"
241246
ff = 3
242247
@named cool_name = foo(42; ff)
243248
@test cool_name[1] == (42,)
244-
@test collect(cool_name[2]) == [:ff => ff; pp]
249+
@test collect(cool_name[2]) == [pp; :ff => ff]
245250

246251
@named cool_name = foo(;ff)
247-
@test collect(cool_name) == [:ff => ff; pp]
252+
@test collect(cool_name) == [pp; :ff => ff]
248253
end

0 commit comments

Comments
 (0)