Skip to content

Commit

Permalink
Add fieldcount (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored Jul 27, 2017
1 parent 3f2391c commit 93cc1fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ Currently, the `@compat` macro supports the following syntaxes:

* `logdet` for `Number`s ([#22629]).

* `fieldcount` is equivalent to `nfields` for Julia versions 0.6 and below and is used to
determine the number of fields in a data type ([#22350]).

## Renamed functions


Expand Down Expand Up @@ -302,6 +305,7 @@ includes this fix. Find the minimum version from there.
[#21346]: https://github.com/JuliaLang/julia/issues/21346
[#22064]: https://github.com/JuliaLang/julia/issues/22064
[#22182]: https://github.com/JuliaLang/julia/issues/22182
[#22350]: https://github.com/JuliaLang/julia/issues/22350
[#22475]: https://github.com/JuliaLang/julia/issues/22475
[#22633]: https://github.com/JuliaLang/julia/issues/22633
[#22629]: https://github.com/JuliaLang/julia/issues/22629
5 changes: 5 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ module Sys
end
end

if VERSION < v"0.7.0-DEV.892"
fieldcount(t) = nfields(t)
export fieldcount
end

include("deprecated.jl")

end # module Compat
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,11 @@ if VERSION < v"0.7.0-DEV.880"
end
end

# PR 22350
eval(Expr(:type, false, :TestType, Expr(:block, :(a::Int), :b)))
@test fieldcount(TestType) == 2
@test fieldcount(Int) == 0

include("deprecated.jl")

nothing

0 comments on commit 93cc1fc

Please sign in to comment.