Skip to content

Commit

Permalink
Fix at-inferred with a single dot-broadcast op
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno authored and mbauman committed Aug 7, 2018
1 parent 176e2e6 commit 6c2a498
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,10 @@ function __dot__(x::Expr)
Expr(x.head, x.args[1], dotargs[2])
else
if x.head == :&& || x.head == :||
Base.depwarn("""
using $(x.head) expressions in @. is deprecated; in the future it will
become elementwise. Break the expression into smaller parts instead.""", nothing)
error("""
Using `&&` and `||` is disallowed in `@.` expressions.
Use `&` or `|` for elementwise logical operations.
""")
end
head = string(x.head)
if last(head) == '=' && first(head) != '.'
Expand Down
8 changes: 7 additions & 1 deletion stdlib/Test/src/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ function get_testset_depth()
end

_args_and_call(args...; kwargs...) = (args[1:end-1], kwargs, args[end](args[1:end-1]...; kwargs...))
_materialize_broadcasted(f, args...) = Broadcast.materialize(Broadcast.broadcasted(f, args...))
"""
@inferred f(x)
Expand Down Expand Up @@ -1294,7 +1295,12 @@ macro inferred(ex)
ex = Expr(:call, :getindex, ex.args...)
end
Meta.isexpr(ex, :call)|| error("@inferred requires a call expression")

farg = ex.args[1]
if isa(farg, Symbol) && first(string(farg)) == '.'
farg = Symbol(string(farg)[2:end])
ex = Expr(:call, GlobalRef(Test, :_materialize_broadcasted),
farg, ex.args[2:end]...)
end
Base.remove_linenums!(quote
let
$(if any(a->(Meta.isexpr(a, :kw) || Meta.isexpr(a, :parameters)), ex.args)
Expand Down

0 comments on commit 6c2a498

Please sign in to comment.