Skip to content

Commit

Permalink
CLEANUP: Special case for unary named tuples in @relation macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
epatters committed Dec 26, 2020
1 parent 0179ff4 commit 759572d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/programs/RelationalPrograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function parse_relation_call(call)
(nothing, parse_relation_kw_args(args)...)
Expr(:tuple) => (nothing, nothing, Symbol[])
Expr(:tuple, args...) => (nothing, parse_relation_inferred_args(args)...)
Expr(:(=), args...) => (nothing, parse_relation_inferred_args([call])...)

_ => error("Invalid syntax in relation $call")
end
Expand Down
4 changes: 4 additions & 0 deletions test/programs/RelationalPrograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ d2 = @relation ((start=u, stop=w) where (u,w,v)) ->
(E(src=u, tgt=v); E(src=v, tgt=w))
@test d1 == d2

# Special case: unary named tuple syntax.
parsed = @relation ((src=v) where (v, w)) -> E(src=v, tgt=w)
@test parsed[:outer_port_name] == [:src]

# Special case: closed diagram.
if VERSION >= v"1.5"
d1 = @relation ((;) where (v,)) -> E(src=v, tgt=v)
Expand Down

0 comments on commit 759572d

Please sign in to comment.