Skip to content

Commit 94e303a

Browse files
committed
Nested ->
1 parent b9f19f2 commit 94e303a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/plugins/meta/meta_macro.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export @meta
22
using MacroTools
33

44
check_for_returns_meta = (x) -> check_for_returns(x; tag = "meta")
5+
not_enter_call_walk = guarded_walk((x) -> x isa Expr && x.head == :call)
56

67
"""
78
add_meta_construction(e::Expr)
@@ -82,7 +83,6 @@ Converts all variable references on the left hand side of a meta specification t
8283
8384
# Examples
8485
"""
85-
8686
function convert_meta_variables(e::Expr)
8787
if @capture(e, (fform_(vars__) -> meta_obj_))
8888
vars = map(var -> __convert_to_indexed_statement(var), vars)
@@ -129,8 +129,10 @@ function convert_meta_object(e::Expr)
129129
end
130130
end
131131

132+
what_walk(::typeof(convert_meta_object)) = not_enter_call_walk
133+
132134
function meta_macro_interior(meta_body::Expr)
133-
meta_body = apply_pipeline(meta_body, (x) -> check_for_returns(x; tag = "meta"))
135+
meta_body = apply_pipeline(meta_body, check_for_returns_meta)
134136
meta_body = add_meta_construction(meta_body)
135137
meta_body = apply_pipeline(meta_body, create_submodel_meta)
136138
meta_body = apply_pipeline(meta_body, convert_meta_variables)

test/plugins/meta/meta_macro_tests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ end
299299
push!(__meta__, GraphPPL.MetaObject(GraphPPL.VariableMetaDescriptor(GraphPPL.IndexedVariable(:x, nothing)), some_meta()))
300300
end
301301
@test_expression_generating apply_pipeline(input, convert_meta_object) output
302+
303+
# Test 3: convert_meta_object with ->
304+
input = quote
305+
ContinuousTransition() -> CTMeta((H) -> reshape(H, dim, dim))
306+
end
307+
output = quote
308+
push!(__meta__, GraphPPL.MetaObject(GraphPPL.FactorMetaDescriptor(ContinuousTransition, ()), CTMeta((H -> reshape(H, dim, dim)))))
309+
end
310+
@test_expression_generating apply_pipeline(input, convert_meta_object) output
302311
end
303312

304313
@testitem "meta_macro_interior" begin

0 commit comments

Comments
 (0)