Skip to content

Commit 6c2a498

Browse files
Kenombauman
authored andcommitted
Fix at-inferred with a single dot-broadcast op
1 parent 176e2e6 commit 6c2a498

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

base/broadcast.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,9 +1079,10 @@ function __dot__(x::Expr)
10791079
Expr(x.head, x.args[1], dotargs[2])
10801080
else
10811081
if x.head == :&& || x.head == :||
1082-
Base.depwarn("""
1083-
using $(x.head) expressions in @. is deprecated; in the future it will
1084-
become elementwise. Break the expression into smaller parts instead.""", nothing)
1082+
error("""
1083+
Using `&&` and `||` is disallowed in `@.` expressions.
1084+
Use `&` or `|` for elementwise logical operations.
1085+
""")
10851086
end
10861087
head = string(x.head)
10871088
if last(head) == '=' && first(head) != '.'

stdlib/Test/src/Test.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ function get_testset_depth()
12561256
end
12571257

12581258
_args_and_call(args...; kwargs...) = (args[1:end-1], kwargs, args[end](args[1:end-1]...; kwargs...))
1259+
_materialize_broadcasted(f, args...) = Broadcast.materialize(Broadcast.broadcasted(f, args...))
12591260
"""
12601261
@inferred f(x)
12611262
@@ -1294,7 +1295,12 @@ macro inferred(ex)
12941295
ex = Expr(:call, :getindex, ex.args...)
12951296
end
12961297
Meta.isexpr(ex, :call)|| error("@inferred requires a call expression")
1297-
1298+
farg = ex.args[1]
1299+
if isa(farg, Symbol) && first(string(farg)) == '.'
1300+
farg = Symbol(string(farg)[2:end])
1301+
ex = Expr(:call, GlobalRef(Test, :_materialize_broadcasted),
1302+
farg, ex.args[2:end]...)
1303+
end
12981304
Base.remove_linenums!(quote
12991305
let
13001306
$(if any(a->(Meta.isexpr(a, :kw) || Meta.isexpr(a, :parameters)), ex.args)

0 commit comments

Comments
 (0)