Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.4, RFC] backports for 0.4.2 #14186

Merged
merged 106 commits into from
Dec 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
488fb5a
preserve inline line numbers during inlining
vtjnash Oct 7, 2015
b8a6d77
fix #922 (wrong line numbers in error expressions) and remove old hac…
vtjnash Oct 7, 2015
e1a3749
Use promote_op in broadcasting and matrix multiplication
timholy Oct 28, 2015
617db6b
Ignore line number node when counting expressions for inlining. Fix #…
yuyichao Oct 11, 2015
d8b91c6
Fix doctests
tkelman Nov 29, 2015
a85dd9f
Non-mutating version of split_decl_rst and more restricted signature …
yuyichao Nov 7, 2015
f02e71d
Ensure the backtrace is shown even if we can't show method candidates
timholy Nov 8, 2015
931cfbe
Method completion using inference to determine the input types to rem…
dhoegh Oct 12, 2015
18000c7
Direct warning to io
timholy Nov 8, 2015
d2c63f4
doc: fix outdated output msg in the assert example [av skip]
gloine Nov 9, 2015
81a214f
doc: fix the assert example to be consistent with doctest output [av …
gloine Nov 9, 2015
6e72687
Added tests for methodshow functions
kshyatt Nov 9, 2015
5efe36c
Add release preparation script
tkelman Nov 9, 2015
d460c68
Add gpg signing commands
tkelman Nov 9, 2015
08d9c7f
Fix socket test on read-only file system
petercolberg Nov 10, 2015
ebe11ae
Pair IO test
kshyatt Nov 11, 2015
6d2b766
Also complete commands (files in the env path) in REPL shell mode
mariushoch Jul 25, 2015
9ee16ff
Inline set_index!(::BitArray, ::Any, ::Int)
carlobaldassi Nov 11, 2015
fc19354
Speed up BitArray packing
carlobaldassi Nov 12, 2015
1b6b761
Avoid branching in unsafe_bitsetindex!
carlobaldassi Nov 12, 2015
53706c3
Fix url(::Method) for no-git builds
tkelman Nov 11, 2015
e880b3b
add license to prepare_release.sh
tkelman Nov 29, 2015
cc31d44
Few more math tests
kshyatt Nov 14, 2015
80724ac
Show and intersection tests
kshyatt Nov 14, 2015
cd06a1f
isprime for various int types
kshyatt Nov 14, 2015
4affae3
Fix type instability in push!
mlubin Nov 13, 2015
5b48286
correct sub2ind_loop() example
scheidan Nov 13, 2015
11cb849
Also check finalizer_list_marked list in jl_finalize. Fix #13986
yuyichao Nov 14, 2015
2df6a67
Add test for old gen finalizer
yuyichao Nov 14, 2015
15bf60d
Tests for OS symbols and windows versions
kshyatt Nov 14, 2015
a534db0
Tests for issparse and indtype
kshyatt Nov 14, 2015
cb2aa46
Add a brief summary of the process of submitting Pkg PRs
timholy Nov 13, 2015
bb90989
avoid running finish_task inside of throw_internal
vtjnash Sep 28, 2015
2ceec96
Fix zip() to return a tuple even when passed a single argument
nalimilan Nov 14, 2015
0e5231f
Do not use system libunwind (0.99) on Travis Linux
yuyichao Nov 16, 2015
3f76dc2
Revert "Disable test for ReadOnlyMemoryError for now since it seems t…
yuyichao Jun 28, 2015
8623f56
REPLCompletions: Allow dirs in PATH that can't be read
mariushoch Nov 12, 2015
6f5177c
Fix build_sysimg on OSX by changing to use cc instead of ld to link s…
dhoegh Nov 16, 2015
f40a611
Fix handling of trailing spaces in REPL shell mode
mariushoch Nov 12, 2015
8662eec
Fixing #13559 with more limited impact. Performance should be identic…
hessammehr Oct 16, 2015
b411724
Unit test for #13559.
hessammehr Oct 17, 2015
51aefcd
Cross-platform test coverage for n-byte reads and throwing EOF on ins…
hessammehr Oct 18, 2015
0958a89
fix the read and write methods of DevNull
bicycle1885 Oct 25, 2015
d497794
count the number of bytes written to DevNull
bicycle1885 Oct 26, 2015
6462964
Fix typo
xanderdunn Nov 19, 2015
231dd4a
improve deprecation warning for non-integer indexing: suggest replaci…
stevengj Nov 18, 2015
8d7683e
normalize literal \r and \r\n chars in string literals to \n (fixes #…
stevengj Nov 20, 2015
1896a57
Add tests for `convert`
zygmuntszpak Nov 21, 2015
eccf231
Add manual section about numerical conversions.
Nov 20, 2015
6d5a859
Add more tests for copysign
zygmuntszpak Nov 20, 2015
0445b3a
Remove trailing white-space
zygmuntszpak Nov 20, 2015
92ad061
remove commented out copysign tests
StefanKarpinski Nov 20, 2015
90584a9
document newline normalization in literal strings (#14073)
stevengj Nov 20, 2015
7704a2a
Make sphinx happy with headings
tkelman Nov 29, 2015
75c791c
edit sync write faq entry [ci skip]
amitmurthy Sep 23, 2015
7afe152
restart worker during tests depending on resident memory size
amitmurthy Oct 13, 2015
f44129f
Fix compilation on Linux (and Possibly other *nix)
yuyichao Oct 15, 2015
a384f8e
limit maxrss check only to travis linux 64-bit
amitmurthy Oct 15, 2015
38d4625
Remove debug print
amitmurthy Oct 15, 2015
ac98b71
simplify channel imp and fix missed put!s
amitmurthy Nov 20, 2015
735fcbf
Fix manual typo
xanderdunn Nov 22, 2015
a308e19
Fix manual typo
xanderdunn Nov 22, 2015
13b6b3a
Add BoundsError tests for getindex
zygmuntszpak Nov 21, 2015
5e8effe
auto completion for true and false. Fix #14101
yuyichao Nov 23, 2015
040435b
Add tests for auto completions of true and false .
yuyichao Nov 23, 2015
8959448
Promote Float32 and Complex{Float32} elements to Float64 and Complex{…
andreasnoack Nov 23, 2015
cc14a34
replace JULIA_CPU_ARCH with JULIA_CPU_TARGET in RPi docs
rdeits Nov 24, 2015
adf54fa
More tests for special functions
kshyatt Nov 24, 2015
95368ee
Added tests for BufferStream
kshyatt Nov 25, 2015
5603ced
fix bug in spawn test's usage of search
tkelman Nov 24, 2015
084a9ad
Comment out assertion on elapsed time in pollfd test
nalimilan Nov 20, 2015
06c9fe3
Tests a few "global" Pkg functions
kshyatt Nov 28, 2015
13a68a0
Fix findmax and findmin with iterables
nalimilan Nov 21, 2015
dcf67a1
Few tests for iobuffer
kshyatt Nov 25, 2015
b3dd88b
Tests for irrationals
kshyatt Nov 25, 2015
38be33e
Quick fix for decompose(::BigFloat) on win64
tkelman Nov 26, 2015
456f38d
fix #12941: remove shutdown syscall from uv_shutdown
vtjnash Nov 29, 2015
bf4eeab
Fix #13926 by also defining ENDCOLOR when VERBOSE=1
tkelman Nov 29, 2015
8b3c67b
fix error on exit for an invalid remote reference
amitmurthy Nov 27, 2015
1085429
Don't show object in whos
andreasnoack Nov 28, 2015
2cba757
initialize temp_dir to empty in Pkg.init
tkelman Nov 30, 2015
4d20f12
Adjust to LLVM 3.8 API changes
Keno Nov 18, 2015
4c33ac6
Add an openblas patch to fix #14174
tkelman Dec 1, 2015
7c7c66f
Revert "Use promote_op in broadcasting and matrix multiplication"
tkelman Dec 1, 2015
64f167f
Take Git/usr/bin off the path on Windows
tkelman Dec 1, 2015
cbebbb7
Fix doctests for reversion of promote_op change
tkelman Dec 1, 2015
89386b4
fix #14027, deepcopy throws UndeRefError on some null Nullables
JeffBezanson Dec 1, 2015
b8382ea
fix #14159, suggest `using Base.Dates` instead of `using Dates`
JeffBezanson Dec 1, 2015
af1cd90
Comment out two assertions on elapsed time in pollfd test
nalimilan Dec 1, 2015
084c906
Don't use shared pkg .cache directory any more on Windows
tkelman Dec 2, 2015
906288e
Fix #14205, package installation on a network drive on Windows
tkelman Dec 2, 2015
b938804
Adjust header comment in juliarc.jl
tkelman Dec 2, 2015
74a3188
Fix nonportable shelling out
tkelman Dec 2, 2015
783c2de
Don't declare something a long and pass it as a size_t
Keno Dec 2, 2015
10defac
Revert "Fix doctests"
tkelman Dec 2, 2015
fa54d22
Revert "Ignore line number node when counting expressions for inlinin…
tkelman Dec 2, 2015
3202b54
Revert "fix #922 (wrong line numbers in error expressions) and remove…
tkelman Dec 2, 2015
9f8ec24
Revert "preserve inline line numbers during inlining"
tkelman Dec 2, 2015
74dcb33
Also remove the problematic pointer case
Keno Dec 3, 2015
f9d049b
Ignore non-rst files when generating stdlib documentation
eschnett Dec 3, 2015
0a268e7
build with assertions enabled on appveyor
tkelman Dec 5, 2015
09b44c2
add a test for reading 128 bit ints from RandomDevice
JeffBezanson Dec 5, 2015
bea4d83
Only apply openblas patch on Windows
tkelman Dec 6, 2015
d0af15f
Fix travis_fastfail.sh for null case
tkelman Dec 5, 2015
c490067
use sudo: false worker on linux travis
tkelman Oct 12, 2015
652d1de
Travis caching adjustments for release-0.4
tkelman Dec 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 41 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
language: cpp
os:
- linux
- osx
env:
- ARCH="i686"
- ARCH="x86_64"
sudo: false
matrix:
exclude:
- os: osx
include:
- os: linux
env: ARCH="i686"
addons:
apt:
packages:
- binutils:i386
- gcc:i386
- g++:i386
- make:i386
- cpp:i386
- libssl-dev:i386
- gfortran:i386
- os: linux
env: ARCH="x86_64"
addons:
apt:
packages:
- gfortran
- os: osx
env: ARCH="x86_64"
cache:
directories:
- $TRAVIS_BUILD_DIR/deps-i686
- $TRAVIS_BUILD_DIR/deps-x86_64
notifications:
email: false
irc:
Expand All @@ -23,28 +40,17 @@ notifications:
before_install:
- make check-whitespace
- if [ `uname` = "Linux" ]; then
sudo apt-get install jq -y;
contrib/travis_fastfail.sh || exit 1;
BUILDOPTS="-j3 USEGCC=1 LLVM_CONFIG=llvm-config-3.3 VERBOSE=1 USE_BLAS64=0 FORCE_ASSERTIONS=1 STAGE2_DEPS=utf8proc";
for lib in LLVM SUITESPARSE ARPACK BLAS FFTW LAPACK GMP MPFR LIBUNWIND OPENLIBM; do
export BUILDOPTS="$BUILDOPTS USE_SYSTEM_$lib=1";
done;
sudo add-apt-repository ppa:staticfloat/julia-deps -y;
sudo apt-get update -qq -y;
BUILDOPTS="-j3 VERBOSE=1 FORCE_ASSERTIONS=1";
if [ "$ARCH" = "i686" ]; then
export BUILDOPTS="$BUILDOPTS MARCH=pentium4";
sudo apt-get remove libblas3gf liblapack3gf libarmadillo2 -y;
sudo apt-get install binutils:i386 -y;
sudo apt-get install gcc:i386 g++:i386 make:i386 cpp:i386 g++-4.6:i386 gcc-4.6:i386 libssl-dev:i386 patchelf:i386 gfortran:i386 llvm-3.3-dev:i386 libsuitesparse-dev:i386 libopenblas-dev:i386 libopenblas-base:i386 libblas-dev:i386 liblapack-dev:i386 liblapack3:i386 libarpack2-dev:i386 libarpack2:i386 libfftw3-dev:i386 libgmp-dev:i386 libpcre3-dev:i386 libunwind7-dev:i386 libopenlibm-dev:i386 libmpfr-dev:i386 -y;
else
sudo apt-get install patchelf gfortran llvm-3.3-dev libsuitesparse-dev libopenblas-dev liblapack-dev libarpack2-dev libfftw3-dev libgmp-dev libpcre3-dev libunwind7-dev libopenlibm-dev libmpfr-dev -y;
fi;
elif [ `uname` = "Darwin" ]; then
brew tap staticfloat/julia;
brew rm --force $(brew deps --HEAD julia);
brew update;
brew install -v jq;
contrib/travis_fastfail.sh || exit 1;
brew tap staticfloat/julia;
brew rm --force $(brew deps --HEAD julia);
brew install -v --only-dependencies --HEAD julia;
BUILDOPTS="-j3 USECLANG=1 LLVM_CONFIG=$(brew --prefix llvm33-julia)/bin/llvm-config-3.3 VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1 STAGE2_DEPS=utf8proc";
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";
Expand All @@ -55,9 +61,11 @@ before_install:
export DYLD_FALLBACK_LIBRARY_PATH="/usr/local/lib:/lib:/usr/lib:$(brew --prefix openblas-julia)/lib:$(brew --prefix suite-sparse-julia)/lib:$(brew --prefix arpack-julia)/lib";
make $BUILDOPTS -C contrib -f repackage_system_suitesparse4.make;
fi
- git clone -q git://git.kitenet.net/moreutils
script:
- if [ -n "`ls deps-$ARCH`" ]; then cp -a deps-$ARCH/* deps; fi
- make $BUILDOPTS -C base version_git.jl.phony
- git clone -q git://git.kitenet.net/moreutils
- make $BUILDOPTS NO_GIT=1 -C deps > deps.log || cat deps.log
- make $BUILDOPTS NO_GIT=1 JULIA_SYSIMG_BUILD_FLAGS="--output-ji ../usr/lib/julia/sys.ji" prefix=/tmp/julia install | moreutils/ts -s "%.s"
- if [ `uname` = "Darwin" ]; then
for name in suitesparseconfig spqr umfpack colamd cholmod amd suitesparse_wrapper; do
Expand All @@ -68,6 +76,13 @@ script:
- cp /tmp/julia/lib/julia/sys.ji local.ji && /tmp/julia/bin/julia -J local.ji -e 'true' && /tmp/julia/bin/julia-debug -J local.ji -e 'true' && rm local.ji
- /tmp/julia/bin/julia -e 'versioninfo()'
- export JULIA_CPU_CORES=2 && cd /tmp/julia/share/julia/test && /tmp/julia/bin/julia --check-bounds=yes runtests.jl all && /tmp/julia/bin/julia --check-bounds=yes runtests.jl pkg
- cd - && mv julia2 julia
- sudo dmesg
- echo "Ready for packaging..."
- cd `dirname $TRAVIS_BUILD_DIR` && mv julia2 julia && rm -f julia/deps/julia-env/src/*/*/*.pyc
- case $TRAVIS_PULL_REQUEST-$TRAVIS_BRANCH in
false-master | false-release*)
cd julia && rm -rf deps-$ARCH && mkdir -p deps-$ARCH &&
for i in $(git ls-files -o --directory deps); do
mv $i deps-$ARCH;
done;;
esac
# uncomment the following if failures are suspected to be due to the out-of-memory killer
# - dmesg
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ VERBOSE = 0
endif

WARNCOLOR="\033[33;1m"
ENDCOLOR="\033[0m"

ifeq ($(VERBOSE), 0)

Expand All @@ -946,7 +947,6 @@ JULIACOLOR="\033[32;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
JULCOLOR="\033[34;1m"
ENDCOLOR="\033[0m"

GOAL=$(subst ','\'',$(subst $(abspath $(JULIAHOME))/,,$(abspath $@)))

Expand Down
2 changes: 1 addition & 1 deletion README.arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ If you run into issues building LLVM, see these notes:
# Raspberry Pi

The Raspberry Pi ARM CPU type is not detected by LLVM.
Before starting the build, it is recommended to do `export JULIA_CPU_ARCH=arm1176jzf-s`
Before starting the build, it is recommended to do `export JULIA_CPU_TARGET=arm1176jzf-s`
at the shell to tune the generated code for your CPU architecture.

# Raspberry Pi 2
Expand Down
121 changes: 112 additions & 9 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ end
function complete_keyword(s::ByteString)
const sorted_keywords = [
"abstract", "baremodule", "begin", "bitstype", "break", "catch", "ccall",
"const", "continue", "do", "else", "elseif", "end", "export", "finally",
"for", "function", "global", "if", "immutable", "import", "importall",
"let", "local", "macro", "module", "quote", "return", "try", "type",
"typealias", "using", "while"]
"const", "continue", "do", "else", "elseif", "end", "export", "false",
"finally", "for", "function", "global", "if", "immutable", "import",
"importall", "let", "local", "macro", "module", "quote", "return",
"true", "try", "type", "typealias", "using", "while"]
r = searchsorted(sorted_keywords, s)
i = first(r)
n = length(sorted_keywords)
Expand All @@ -109,7 +109,7 @@ function complete_keyword(s::ByteString)
sorted_keywords[r]
end

function complete_path(path::AbstractString, pos)
function complete_path(path::AbstractString, pos; use_envpath=false)
if Base.is_unix(OS_NAME) && ismatch(r"^~(?:/|$)", path)
# if the path is just "~", don't consider the expanded username as a prefix
if path == "~"
Expand Down Expand Up @@ -141,6 +141,49 @@ function complete_path(path::AbstractString, pos)
push!(matches, id ? file * (@windows? "\\\\" : "/") : file)
end
end

if use_envpath && length(dir) == 0
# Look for files in PATH as well
local pathdirs = split(ENV["PATH"], @unix? ":" : ";")

for pathdir in pathdirs
local actualpath
try
actualpath = realpath(pathdir)
catch
# Bash doesn't expect every folder in PATH to exist, so neither shall we
continue
end

if actualpath != pathdir && in(actualpath,pathdirs)
# Remove paths which (after resolving links) are in the env path twice.
# Many distros eg. point /bin to /usr/bin but have both in the env path.
continue
end

local filesinpath
try
filesinpath = readdir(pathdir)
catch e
# Bash allows dirs in PATH that can't be read, so we should as well.
if isa(e, SystemError)
continue
else
# We only handle SystemErrors here
rethrow(e)
end
end

for file in filesinpath
# In a perfect world, we would filter on whether the file is executable
# here, or even on whether the current user can execute the file in question.
if startswith(file, prefix) && isfile(joinpath(pathdir, file))
push!(matches, file)
end
end
end
end

matches = UTF8String[replace(s, r"\s", "\\ ") for s in matches]
startpos = pos - endof(prefix) + 1 - length(matchall(r" ", prefix))
# The pos - endof(prefix) + 1 is correct due to `endof(prefix)-endof(prefix)==0`,
Expand Down Expand Up @@ -222,14 +265,64 @@ get_value(sym::Symbol, fn) = isdefined(fn, sym) ? (fn.(sym), true) : (nothing, f
get_value(sym::QuoteNode, fn) = isdefined(fn, sym.value) ? (fn.(sym.value), true) : (nothing, false)
get_value(sym, fn) = sym, true

# Return the value of a getfield call expression
function get_value_getfield(ex::Expr, fn)
# Example :((top(getfield))(Base,:max))
val, found = get_value_getfield(ex.args[2],fn) #Look up Base in Main and returns the module
found || return (nothing, false)
get_value_getfield(ex.args[3],val) #Look up max in Base and returns the function if found.
end
get_value_getfield(sym, fn) = get_value(sym, fn)
# Determines the return type with Base.return_types of a function call using the type information of the arguments.
function get_type_call(expr::Expr)
f_name = expr.args[1]
# The if statement should find the f function. How f is found depends on how f is referenced
if isa(f_name, TopNode)
f = Base.(f_name.name)
found = true
elseif isa(f_name, Expr) && f_name.args[1] === TopNode(:getfield)
f, found = get_value_getfield(f_name, Main)
else
f, found = get_value(f_name, Main)
end
found || return (Any, false) # If the function f is not found return Any.
args = Any[]
for ex in expr.args[2:end] # Find the type of the function arguments
typ, found = get_type(ex, Main)
found ? push!(args, typ) : push!(args, Any)
end
return_types = Base.return_types(f,Tuple{args...})
length(return_types) == 1 || return (Any, false)
return (return_types[1], true)
end
# Returns the return type. example: get_type(:(Base.strip("",' ')),Main) returns (ASCIIString,true)
function get_type(sym::Expr, fn)
sym=expand(sym)
val, found = get_value(sym, fn)
found && return Base.typesof(val).parameters[1], found
if sym.head === :call
# getfield call is special cased as the evaluation of getfield provides good type information,
# is inexpensive and it is also performed in the complete_symbol function.
if sym.args[1] === TopNode(:getfield)
val, found = get_value_getfield(sym, Main)
return found ? Base.typesof(val).parameters[1] : Any, found
end
return get_type_call(sym)
end
(Any, false)
end
function get_type(sym, fn)
val, found = get_value(sym, fn)
return found ? Base.typesof(val).parameters[1] : Any, found
end
# Method completion on function call expression that look like :(max(1))
function complete_methods(ex_org::Expr)
args_ex = DataType[]
func, found = get_value(ex_org.args[1], Main)
(!found || (found && !isgeneric(func))) && return UTF8String[]
for ex in ex_org.args[2:end]
val, found = get_value(ex, Main)
found ? push!(args_ex, Base.typesof(val).parameters[1]) : push!(args_ex, Any)
val, found = get_type(ex, Main)
push!(args_ex, val)
end
out = UTF8String[]
t_in = Tuple{args_ex...} # Input types
Expand Down Expand Up @@ -390,8 +483,18 @@ function shell_completions(string, pos)
isempty(args.args[end].args) && return UTF8String[], 0:-1, false
arg = args.args[end].args[end]
if all(s -> isa(s, AbstractString), args.args[end].args)
# Treat this as a path (perhaps give a list of commands in the future as well?)
return complete_path(join(args.args[end].args), pos)
# Treat this as a path

# As Base.shell_parse throws away trailing spaces (unless they are escaped),
# we need to special case here.
# If the last char was a space, but shell_parse ignored it search on "".
ignore_last_word = arg != " " && scs[end] == ' '
prefix = ignore_last_word ? "" : join(args.args[end].args)

# Also try looking into the env path if the user wants to complete the first argument
use_envpath = !ignore_last_word && length(args.args) < 2

return complete_path(prefix, pos, use_envpath=use_envpath)
elseif isexpr(arg, :escape) && (isexpr(arg.args[1], :incomplete) || isexpr(arg.args[1], :error))
r = first(last_parse):prevind(last_parse, last(last_parse))
partial = scs[r]
Expand Down
3 changes: 0 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,6 @@ start(A::AbstractArray) = (@_inline_meta(); itr = eachindex(A); (itr, start(itr)
next(A::AbstractArray,i) = (@_inline_meta(); (idx, s) = next(i[1], i[2]); (A[idx], (i[1], s)))
done(A::AbstractArray,i) = done(i[1], i[2])

iterstate(i) = i
iterstate(i::Tuple{UnitRange{Int},Int}) = i[2]

# eachindex iterates over all indices. LinearSlow definitions are later.
eachindex(A::AbstractArray) = (@_inline_meta(); eachindex(linearindexing(A), A))

Expand Down
36 changes: 18 additions & 18 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ end

function push!{T}(a::Array{T,1}, item)
# convert first so we don't grow the array if the assignment won't work
item = convert(T, item)
itemT = convert(T, item)
ccall(:jl_array_grow_end, Void, (Any, UInt), a, 1)
a[end] = item
a[end] = itemT
return a
end

Expand Down Expand Up @@ -830,36 +830,36 @@ function findmax(a)
if isempty(a)
throw(ArgumentError("collection must be non-empty"))
end
i = start(a)
mi = i
m, i = next(a, i)
while !done(a, i)
iold = i
ai, i = next(a, i)
s = start(a)
mi = i = 1
m, s = next(a, s)
while !done(a, s)
ai, s = next(a, s)
i += 1
if ai > m || m!=m
m = ai
mi = iold
mi = i
end
end
return (m, iterstate(mi))
return (m, mi)
end

function findmin(a)
if isempty(a)
throw(ArgumentError("collection must be non-empty"))
end
i = start(a)
mi = i
m, i = next(a, i)
while !done(a, i)
iold = i
ai, i = next(a, i)
s = start(a)
mi = i = 1
m, s = next(a, s)
while !done(a, s)
ai, s = next(a, s)
i += 1
if ai < m || m!=m
m = ai
mi = iold
mi = i
end
end
return (m, iterstate(mi))
return (m, mi)
end

indmax(a) = findmax(a)[2]
Expand Down
Loading