Skip to content

Commit 5fb7f94

Browse files
committed
make all maketerm arguments mandatory
Fixes #33
1 parent 4459f42 commit 5fb7f94

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/TermInterface.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ end
111111

112112

113113
"""
114-
maketerm(T, head, children, type=nothing, metadata=nothing)
114+
maketerm(T, head, children, type, metadata)
115115
116116
Constructs an expression. `T` is a constructor type, `head` and `children` are
117117
the head and tail of the S-expression, `type` is the `type` of the S-expression.
@@ -127,11 +127,10 @@ the sub-expression. `T` will be the type of the outer expression.
127127
128128
Packages providing expression types _must_ implement this method for each expression type.
129129
130-
If your types do not support type information or metadata, you still need to accept
131-
these arguments and may choose to not use them.
130+
Giving `nothing` for `type` or `metadata` results in a default being selected.
132131
"""
133132

134-
function maketerm(T::Type, head, children, type=nothing, metadata=nothing)
133+
function maketerm(T::Type, head, children, type, metadata)
135134
error("maketerm for $T is not implemented")
136135
end
137136
export maketerm

src/expr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ children(e::Expr) = e.args
1010
operation(e::Expr) = iscall(e) ? first(children(e)) : error("operation called on a non-function call expression")
1111
arguments(e::Expr) = iscall(e) ? @view(e.args[2:end]) : error("arguments called on a non-function call expression")
1212

13-
function maketerm(::Type{Expr}, head, args, type=nothing, metadata=nothing)
13+
function maketerm(::Type{Expr}, head, args, type, metadata)
1414
Expr(head, args...)
1515
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using Test
99
@test arguments(ex) == [:a, :b]
1010
@test isexpr(ex)
1111
@test iscall(ex)
12-
@test ex == maketerm(Expr, :call, [:f, :a, :b])
12+
@test ex == maketerm(Expr, :call, [:f, :a, :b], nothing, nothing)
1313

1414

1515
ex = :(arr[i, j])
@@ -18,5 +18,5 @@ using Test
1818
@test_throws ErrorException arguments(ex)
1919
@test isexpr(ex)
2020
@test !iscall(ex)
21-
@test ex == maketerm(Expr, :ref, [:arr, :i, :j])
21+
@test ex == maketerm(Expr, :ref, [:arr, :i, :j], nothing, nothing)
2222
end

0 commit comments

Comments
 (0)