From 7ce6a5e3febd873b75bdc60de135209ae36c13ec Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Thu, 17 Mar 2022 06:40:12 -0500 Subject: [PATCH 1/2] Add examples to LazyString docstrings (#44514) --- base/strings/lazy.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/base/strings/lazy.jl b/base/strings/lazy.jl index a2f872c40660e..4d918807a3576 100644 --- a/base/strings/lazy.jl +++ b/base/strings/lazy.jl @@ -9,6 +9,15 @@ of functions). This type is designed to be cheap to construct at runtime, trying to offload as much work as possible to either the macro or later printing operations. +# Examples + +```jldoctest +julia> n = 5; str = LazyString("n is ", n) +"n is 5" +``` + +See also [`lazy"str"`](@ref). + !!! compat "Julia 1.8" `LazyString` requires Julia 1.8 or later. """ @@ -26,6 +35,16 @@ Create a [`LazyString`](@ref) using regular string interpolation syntax. Note that interpolations are *evaluated* at LazyString construction time, but *printing* is delayed until the first access to the string. +# Examples + +``` +julia> n = 5; str = lazy"n is \$n" +"n is 5" + +julia> typeof(str) +LazyString +``` + !!! compat "Julia 1.8" `lazy"str"` requires Julia 1.8 or later. """ From b9b2a3cc01404e019682e75e3c5241f105031511 Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Thu, 17 Mar 2022 08:03:15 -0400 Subject: [PATCH 2/2] fix regression introduced in #44231 (#44638) ref https://github.com/JuliaLang/julia/pull/44231#issuecomment-1069052669 --- base/compiler/tfuncs.jl | 6 +++--- test/compiler/irpasses.jl | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index df1861e20c206..0807989f1aa47 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -1811,11 +1811,11 @@ function builtin_effects(f::Builtin, argtypes::Vector{Any}, rt) nothrow = isvarargtype(argtypes[end]) ? false : builtin_nothrow(f, argtypes[2:end], rt) end - effect_free = f === isdefined + effect_free = true elseif f === getglobal && length(argtypes) >= 3 - nothrow = effect_free = getglobal_nothrow(argtypes[2:end]) + nothrow = getglobal_nothrow(argtypes[2:end]) ipo_consistent = nothrow && isconst((argtypes[2]::Const).val, (argtypes[3]::Const).val) - #effect_free = nothrow && isbindingresolved((argtypes[2]::Const).val, (argtypes[3]::Const).val) + effect_free = true else ipo_consistent = contains_is(_CONSISTENT_BUILTINS, f) effect_free = contains_is(_EFFECT_FREE_BUILTINS, f) || contains_is(_PURE_BUILTINS, f) diff --git a/test/compiler/irpasses.jl b/test/compiler/irpasses.jl index 128fd6cc84b7b..38f60b0fd12aa 100644 --- a/test/compiler/irpasses.jl +++ b/test/compiler/irpasses.jl @@ -831,3 +831,6 @@ let ci = code_typed(foo_cfg_empty, Tuple{Bool}, optimize=true)[1][1] @test length(ir.cfg.blocks) <= 2 @test isa(ir.stmts[length(ir.stmts)][:inst], ReturnNode) end + +@test Core.Compiler.builtin_effects(getfield, Any[Complex{Int}, Symbol], Any).effect_free.state == 0x01 +@test Core.Compiler.builtin_effects(getglobal, Any[Module, Symbol], Any).effect_free.state == 0x01