diff --git a/src/macro.jl b/src/macro.jl index 144b7e05..f0b45cfe 100644 --- a/src/macro.jl +++ b/src/macro.jl @@ -21,7 +21,7 @@ macro !(expr) lhs, rhs = x.args return :($lhs = $materialize!!( $Base.@isdefined($lhs) ? $lhs : $(Undefined()), - $rhs, + $air.($rhs), )) end return x @@ -39,3 +39,10 @@ function undotoperator(x::Symbol) Base.isoperator(op) || return nothing return op end + +function air end +struct Aired{T} + value::T +end +@inline Broadcast.broadcasted(::typeof(air), x) = Aired(x) +@inline Broadcast.materialize(x::Aired) = x.value diff --git a/test/test_materialize.jl b/test/test_materialize.jl index de0fc1f5..da2a05e3 100644 --- a/test/test_materialize.jl +++ b/test/test_materialize.jl @@ -1,13 +1,7 @@ module TestMaterialize include("preamble.jl") - -function air end -struct Aired{T} - value::T -end -@inline Broadcast.broadcasted(::typeof(air), x) = Aired(x) -@inline Broadcast.materialize(x::Aired) = x.value +using BangBang: air @testset begin @test materialize!!(nothing, air.([0, 1] .+ 2))::Vector{Int} == [2, 3]