Skip to content

Commit 8c3dff2

Browse files
committed
fix Informative error message at macro eval time for extra arguments #48
1 parent 161508f commit 8c3dff2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArgCheck"
22
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
33
license = "MIT"
4-
version = "2.4.0"
4+
version = "2.4.1"
55

66
[compat]
77
julia = "1"

src/checks.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080
See also [`@check`](@ref).
8181
"""
8282
macro argcheck(ex, options...)
83-
check(ex, ArgCheckFlavor(), options...)
83+
checkmacro(ex, ArgCheckFlavor(), options...)
8484
end
8585

8686
"""
@@ -97,10 +97,13 @@ Usage is as follows:
9797
See also [`@argcheck`](@ref).
9898
"""
9999
macro check(ex, options...)
100-
check(ex, CheckFlavor(), options...)
100+
checkmacro(ex, CheckFlavor(), options...)
101101
end
102102

103-
function check(ex, checkflavor, options...)
103+
function checkmacro(ex, checkflavor, options...)
104+
if length(options) > 1
105+
error("Too many arguments for @check/@argcheck macro")
106+
end
104107
codeflavor = if isexpr(ex, :comparison)
105108
ComparisonFlavor()
106109
elseif isexpr(ex, :call)

test/checks.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,10 @@ end
308308
@test Meta.isexpr(ArgCheck.LABEL_END_CHECK, :meta)
309309
end
310310

311+
@testset "Informative error message at macro eval time for extra arguments #48" begin
312+
# https://github.com/jw3126/ArgCheck.jl/issues/48
313+
@test_throws "Too many arguments" @macroexpand( @argcheck 1 == 1 1.8 "That's good")
314+
@test_throws "Too many arguments" @macroexpand( @argcheck 1 == 2 1.8 "That's good")
315+
end
316+
311317
end#module

0 commit comments

Comments
 (0)