Skip to content

Commit 98f69ca

Browse files
authored
fix Informative error message at macro eval time for extra arguments #48 (#49)
* fix Informative error message at macro eval time for extra arguments #48 * try fix ci * bump julia compat
1 parent 161508f commit 98f69ca

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.0'
14-
- '1.1'
13+
- '1.10' # lts
1514
- '1'
1615
- 'nightly'
1716
os:
@@ -27,15 +26,5 @@ jobs:
2726
version: ${{ matrix.version }}
2827
arch: ${{ matrix.arch }}
2928
show-versioninfo: true
30-
- uses: actions/cache@v1
31-
env:
32-
cache-name: cache-artifacts
33-
with:
34-
path: ~/.julia/artifacts
35-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
36-
restore-keys: |
37-
${{ runner.os }}-test-${{ env.cache-name }}-
38-
${{ runner.os }}-test-
39-
${{ runner.os }}-
4029
- uses: julia-actions/julia-buildpkg@latest
4130
- uses: julia-actions/julia-runtest@latest

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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]
7-
julia = "1"
7+
julia = "1.10"
88

99
[extras]
1010
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"

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)