Skip to content

Commit

Permalink
Merge pull request #11 from simonbyrne/sb/nested-where
Browse files Browse the repository at this point in the history
Allow multiple where statements
  • Loading branch information
simonbyrne authored Sep 25, 2020
2 parents 704a91e + a3449e1 commit 1aef7d5
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI
on:
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.0'
- '1.4'
- '1.5'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manifest.toml
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name = "KeywordDispatch"
uuid = "5888135b-5456-5c80-a1b6-c91ef8180460"
authors = ["Simon Byrne <simonbyrne@gmail.com>"]
version = "0.3.0"
version = "0.3.1"

[deps]
[compat]
julia = "1.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
2 changes: 1 addition & 1 deletion src/KeywordDispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ argtype(x::Expr) = x.head == :(::) ? x.args[end] : error("unexpected expression
function unwrap_where(expr)
stack = Any[]
while expr isa Expr && expr.head == :where
push!(stack, expr.args[2])
append!(stack, expr.args[2:end])
expr = expr.args[1]
end
expr, stack
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,15 @@ end

@test f(alpha=0,beta=0) == 3
end

@testset "multiple where clauses" begin
# based on https://github.com/simonbyrne/KeywordDispatch.jl/issues/9
@kwdispatch f(x::T) where {T}

@kwmethod f(x::T; y::TI) where {T, TI <: Vector{T}} = y

@test f(1.0,y=[1.0,2.0]) == [1.0,2.0]
@test f(1,y=[1,2]) == [1,2]

@test_throws KeywordMethodError f(1,y=[1.0,2.0])
end

2 comments on commit 1aef7d5

@simonbyrne
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/22002

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 1aef7d583acbd0d6525fd8e41b5af77b2b330dcd
git push origin v0.3.1

Please sign in to comment.