Browse Source

CLEANUP: Special case for unary named tuples in `@relation` macro.

pull/365/head
Evan Patterson 1 month ago
parent
commit
759572d0c1
2 changed files with 5 additions and 0 deletions
  1. +1
    -0
      src/programs/RelationalPrograms.jl
  2. +4
    -0
      test/programs/RelationalPrograms.jl

+ 1
- 0
src/programs/RelationalPrograms.jl View File

@ -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


+ 4
- 0
test/programs/RelationalPrograms.jl View File

@ -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)


Loading…
Cancel
Save