diff --git a/Makefile b/Makefile index 274c0f8b7cc4c4..4644130d5914f4 100644 --- a/Makefile +++ b/Makefile @@ -343,7 +343,7 @@ endif mkdir -p $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/ $(INSTALL_F) $(JULIAHOME)/contrib/julia.svg $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/ -touch -c $(DESTDIR)$(datarootdir)/icons/hicolor/ - -gtk-update-icon-cache $(DESTDIR)$(datarootdir)/icons/hicolor/ + -gtk-update-icon-cache --ignore-theme-index $(DESTDIR)$(datarootdir)/icons/hicolor/ mkdir -p $(DESTDIR)$(datarootdir)/applications/ $(INSTALL_F) $(JULIAHOME)/contrib/julia.desktop $(DESTDIR)$(datarootdir)/applications/ # Install appdata file diff --git a/base/broadcast.jl b/base/broadcast.jl index 8dd85622b55e30..24d0424a897273 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -384,13 +384,45 @@ end ## logic for deciding the BroadcastStyle -# combine_styles operates on values (arbitrarily many) +""" + combine_styles(cs...) -> BroadcastStyle + +Decides which `BroadcastStyle` to use for any number of value arguments. +Uses [`BroadcastStyle`](@ref) to get the style for each argument, and uses +[`result_style`](@ref) to combine styles. + +# Examples + +```jldoctest +julia> Broadcast.combine_styles([1], [1 2; 3 4]) +Base.Broadcast.DefaultArrayStyle{2}() +``` +""" +function combine_styles end + combine_styles() = DefaultArrayStyle{0}() combine_styles(c) = result_style(BroadcastStyle(typeof(c))) combine_styles(c1, c2) = result_style(combine_styles(c1), combine_styles(c2)) @inline combine_styles(c1, c2, cs...) = result_style(combine_styles(c1), combine_styles(c2, cs...)) -# result_style works on types (singletons and pairs), and leverages `BroadcastStyle` +""" + result_style(s1::BroadcastStyle[, s2::BroadcastStyle]) -> BroadcastStyle + +Takes one or two `BroadcastStyle`s and combines them using [`BroadcastStyle`](@ref) to +determine a common `BroadcastStyle`. + +# Examples + +```jldoctest +julia> Broadcast.result_style(Broadcast.DefaultArrayStyle{0}(), Broadcast.DefaultArrayStyle{3}()) +Base.Broadcast.DefaultArrayStyle{3}() + +julia> Broadcast.result_style(Broadcast.Unknown(), Broadcast.DefaultArrayStyle{1}()) +Base.Broadcast.DefaultArrayStyle{1}() +``` +""" +function result_style end + result_style(s::BroadcastStyle) = s result_style(s1::S, s2::S) where S<:BroadcastStyle = S() # Test both orders so users typically only have to declare one order @@ -418,6 +450,20 @@ One of these should be undefined (and thus return Broadcast.Unknown).""") end # Indices utilities + +""" + combine_axes(As...) -> Tuple + +Determine the result axes for broadcasting across all values in `As`. + +```jldoctest +julia> Broadcast.combine_axes([1], [1 2; 3 4; 5 6]) +(Base.OneTo(3), Base.OneTo(2)) + +julia> Broadcast.combine_axes(1, 1, 1) +() +``` +""" @inline combine_axes(A, B...) = broadcast_shape(axes(A), combine_axes(B...)) combine_axes(A) = axes(A) diff --git a/doc/src/base/arrays.md b/doc/src/base/arrays.md index 6cad1e62b8e3ab..58052238bf798e 100644 --- a/doc/src/base/arrays.md +++ b/doc/src/base/arrays.md @@ -80,6 +80,9 @@ Base.Broadcast.AbstractArrayStyle Base.Broadcast.ArrayStyle Base.Broadcast.DefaultArrayStyle Base.Broadcast.broadcastable +Base.Broadcast.combine_axes +Base.Broadcast.combine_styles +Base.Broadcast.result_style ``` ## Indexing and assignment diff --git a/doc/src/manual/variables.md b/doc/src/manual/variables.md index 317b1622173bf7..0ede5e771d8403 100644 --- a/doc/src/manual/variables.md +++ b/doc/src/manual/variables.md @@ -81,13 +81,13 @@ julia> pi π = 3.1415926535897... julia> pi = 3 -ERROR: cannot assign variable MathConstants.pi from module Main +ERROR: cannot assign a value to variable MathConstants.pi from module Main julia> sqrt(100) 10.0 julia> sqrt = 4 -ERROR: cannot assign variable Base.sqrt from module Main +ERROR: cannot assign a value to variable Base.sqrt from module Main ``` ## Allowed Variable Names diff --git a/src/codegen.cpp b/src/codegen.cpp index 85b8db65210c74..83bfcbe9071bc9 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3243,7 +3243,7 @@ static Value *global_binding_pointer(jl_codectx_t &ctx, jl_module_t *m, jl_sym_t assert(b != NULL); if (b->owner != m) { char *msg; - (void)asprintf(&msg, "cannot assign variable %s.%s from module %s", + (void)asprintf(&msg, "cannot assign a value to variable %s.%s from module %s", jl_symbol_name(b->owner->name), jl_symbol_name(s), jl_symbol_name(m->name)); emit_error(ctx, msg); free(msg); diff --git a/src/module.c b/src/module.c index e2ee5e4f2ae7e5..5651a069491acd 100644 --- a/src/module.c +++ b/src/module.c @@ -114,7 +114,7 @@ JL_DLLEXPORT jl_binding_t *jl_get_binding_wr(jl_module_t *m, jl_sym_t *var, int b->owner = m; } else if (error) { - jl_errorf("cannot assign variable %s.%s from module %s", + jl_errorf("cannot assign a value to variable %s.%s from module %s", jl_symbol_name(b->owner->name), jl_symbol_name(var), jl_symbol_name(m->name)); } } diff --git a/stdlib/SHA/test/runtests.jl b/stdlib/SHA/test/runtests.jl index 63a333bdf779d6..ce0d2b68fdbacb 100644 --- a/stdlib/SHA/test/runtests.jl +++ b/stdlib/SHA/test/runtests.jl @@ -9,7 +9,8 @@ const VERBOSE = false lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." so_many_as_array = repeat([0x61], 1000000) so_many_as_tuple = ntuple((i) -> 0x61, 1000000) -file = ".sha" # Subject to change +tempdir = mktempdir() +file = joinpath(tempdir, ".sha") fIO = open(file, "w") write(fIO, '\0') close(fIO) @@ -274,16 +275,24 @@ end # test error if eltype of input is not UInt8 for f in sha_funcs global nerrors + data = UInt32[0x23467, 0x324775] try - f(UInt32[0x23467, 0x324775]) - warn("Non-UInt8 Arrays should fail") - nerrors += 1 - catch + f(data) + catch ex + if ex isa MethodError && + ex.f === f && + ex.args === (data,) + continue + end + rethrow() end + warn("Non-UInt8 Arrays should fail") + nerrors += 1 end # Clean up the I/O mess rm(file) +rm(tempdir) if nerrors == 0 VERBOSE && println("ALL OK")