Skip to content

Commit 077d6e5

Browse files
committed
fix for 1.0
1 parent 38b2aec commit 077d6e5

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
version:
20+
- '1.0'
2021
- '1.6' # Replace this with the minimum Julia version that your package supports.
2122
- '1' # automatically expands to the latest stable 1.x release of Julia
2223
- 'nightly'

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ authors = ["Mike J Innes <mike.j.innes@gmail.com>"]
44
version = "0.2.8"
55

66
[compat]
7-
julia = "1.6"
87
Documenter = "0.27"
8+
julia = "1"
99

1010
[extras]
1111
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

src/Functors.jl

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ usually using the macro [@functor](@ref).
2323
"""
2424
functor
2525

26+
@static if VERSION >= v"1.5" # var"@functor" doesn't work on 1.0, temporarily disable
2627
"""
2728
@functor T
2829
@functor T (x,)
@@ -65,6 +66,7 @@ TwoThirds(Foo(10, 20), Foo(3, 4), 560)
6566
```
6667
"""
6768
var"@functor"
69+
end # VERSION
6870

6971
"""
7072
Functors.isleaf(x)

src/functor.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct NoKeyword end
4747

4848
function fmap(f, x; exclude = isleaf, walk = _default_walk, cache = IdDict(), prune = NoKeyword())
4949
haskey(cache, x) && return prune isa NoKeyword ? cache[x] : prune
50-
cache[x] = exclude(x) ? f(x) : walk(x -> fmap(f, x; exclude, walk, cache, prune), x)
50+
cache[x] = exclude(x) ? f(x) : walk(x -> fmap(f, x; exclude=exclude, walk=walk, cache=cache, prune=prune), x)
5151
end
5252

5353
###
@@ -75,7 +75,7 @@ end
7575

7676
function fmap(f, x, ys...; exclude = isleaf, walk = _default_walk, cache = IdDict(), prune = NoKeyword())
7777
haskey(cache, x) && return prune isa NoKeyword ? cache[x] : prune
78-
cache[x] = exclude(x) ? f(x, ys...) : walk((xy...,) -> fmap(f, xy...; exclude, walk, cache, prune), x, ys...)
78+
cache[x] = exclude(x) ? f(x, ys...) : walk((xy...,) -> fmap(f, xy...; exclude=exclude, walk=walk, cache=cache, prune=prune), x, ys...)
7979
end
8080

8181
function _default_walk(f, x, ys...)

test/basics.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,12 @@ end
182182
@test z4.x === z4.z
183183

184184
@test fmap(+, foo1, m1, n1) isa Foo
185-
@test fmap(.*, m1, foo1, n1) == (x = [4*7, 2*5*8], y = 3*6*9)
185+
@static if VERSION >= v"1.6" # fails on Julia 1.0
186+
@test fmap(.*, m1, foo1, n1) == (x = [4*7, 2*5*8], y = 3*6*9)
187+
end
186188
end
187189

190+
@static if VERSION >= v"1.6" # Julia 1.0: LoadError: error compiling top-level scope: type definition not allowed inside a local scope
188191
@testset "old test update.jl" begin
189192
struct M{F,T,S}
190193
σ::F
@@ -208,6 +211,7 @@ end
208211
@test.W fill(0.8f0, size(m.W))
209212
@test.b fill(-0.2f0, size(m.b))
210213
end
214+
end # VERSION
211215

212216
###
213217
### FlexibleFunctors.jl

0 commit comments

Comments
 (0)