Skip to content

Commit f8d0e78

Browse files
committed
Add getmetadata methods bc metadata kwarg takes outer-scope function
in `BasicSymbolic` constructors
1 parent 29a6eb4 commit f8d0e78

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/types.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ _issafecanon(::typeof(^), s) = !iscall(s) || !(operation(s) in (*, ^))
935935

936936
issafecanon(f, ss...) = all(x->issafecanon(f, x), ss)
937937

938+
getmetadata(s) = metadata(s)
938939
function getmetadata(s::Symbolic, ctx)
939940
md = metadata(s)
940941
if md isa AbstractDict
@@ -943,11 +944,13 @@ function getmetadata(s::Symbolic, ctx)
943944
throw(ArgumentError("$s does not have metadata for $ctx"))
944945
end
945946
end
946-
947947
function getmetadata(s::Symbolic, ctx, default)
948948
md = metadata(s)
949949
md isa AbstractDict ? get(md, ctx, default) : default
950950
end
951+
function getmetadata(d::AbstractDict, ctx)
952+
d[ctx]
953+
end
951954

952955
# pirated for Setfield purposes:
953956
using Base: ImmutableDict

0 commit comments

Comments
 (0)