Skip to content

Commit 04477f6

Browse files
committed
Return vcat of all named objects
1 parent e9a2b83 commit 04477f6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/systems/abstractsystem.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,13 @@ end
958958
function named_expr(expr)
959959
if Meta.isexpr(expr, :block)
960960
newexpr = Expr(:block)
961+
names = Expr(:vcat)
961962
for ex in expr.args
962963
ex isa LineNumberNode && continue
963964
push!(newexpr.args, single_named_expr(ex))
965+
push!(names.args, ex.args[1])
964966
end
967+
push!(newexpr.args, names)
965968
newexpr
966969
else
967970
single_named_expr(expr)
@@ -979,7 +982,7 @@ end
979982
@named begin
980983
y[1:10] = foo(x)
981984
z = foo(x)
982-
end
985+
end # returns `[y; z]`
983986
@named y 1:10 i -> foo(x*i) # This is not recommended
984987
985988
Pass the LHS name to the model. When it's calling anything that's not an

test/direct.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ foo(i; name) = (; i, name)
257257
@test isequal(goo, [(i = 10, name = Symbol(:goo_, i)) for i in 1:3])
258258
@named koo 1:3 i->foo(10i)
259259
@test isequal(koo, [(i = 10i, name = Symbol(:koo_, i)) for i in 1:3])
260-
@named begin
260+
xys = @named begin
261261
x = foo(12)
262262
y[1:3] = foo(13)
263263
end
264264
@test isequal(x, (i = 12, name = :x))
265265
@test isequal(y, [(i = 13, name = Symbol(:y_, i)) for i in 1:3])
266+
@test isequal(xys, [x; y])

0 commit comments

Comments
 (0)