Skip to content

Commit 2e571fe

Browse files
authored
Run on 1.9+ (#93)
* run on nightly * backing_error
1 parent 55d2871 commit 2e571fe

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/extra_rules.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,6 @@ function ChainRulesCore.rrule(::DiffractorRuleConfig, ::Type{InplaceableThunk},
259259
end
260260

261261
Base.real(z::NoTangent) = z # TODO should be in CRC, https://github.com/JuliaDiff/ChainRulesCore.jl/pull/581
262+
263+
# Avoid https://github.com/JuliaDiff/ChainRulesCore.jl/pull/495
264+
ChainRulesCore._backing_error(P::Type{<:Base.Pairs}, G::Type{<:NamedTuple}, E::Type{<:AbstractDict}) = nothing

src/stage1/compiler_utils.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ function Base.setindex!(ir::Core.Compiler.IRCode, ni::NewInstruction, i::Int)
2323
stmt = ir.stmts[i]
2424
stmt.inst = ni.stmt
2525
stmt.type = ni.type
26-
stmt.flag = ni.flag
26+
stmt.flag = something(ni.flag, 0) # fixes 1.9?
2727
stmt.line = something(ni.line, 0)
2828
ni
2929
end
3030

3131
function Base.push!(ir::IRCode, ni::NewInstruction)
3232
# TODO: This should be a check in insert_node!
3333
@assert length(ir.new_nodes.stmts) == 0
34-
ir[Core.Compiler.add!(ir.stmts)] = ni
34+
@static if isdefined(Core.Compiler, :add!)
35+
# Julia 1.7 & 1.8
36+
ir[Core.Compiler.add!(ir.stmts)] = ni
37+
else
38+
# Re-named in https://github.com/JuliaLang/julia/pull/47051
39+
ir[Core.Compiler.add_new_idx!(ir.stmts)] = ni
40+
end
3541
ir
3642
end
3743

@@ -47,3 +53,9 @@ end
4753

4854
Base.lastindex(x::Core.Compiler.InstructionStream) =
4955
Core.Compiler.length(x)
56+
57+
# Solves an error after https://github.com/JuliaLang/julia/pull/46961
58+
# as does https://github.com/FluxML/IRTools.jl/pull/101
59+
if isdefined(Core.Compiler, :CallInfo)
60+
Base.convert(::Type{Core.Compiler.CallInfo}, ::Nothing) = Core.Compiler.NoCallInfo()
61+
end

src/stage1/hacks.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Updated copy of the same code in Base, but with bugs fixed
2-
using Core.Compiler: count_added_node!, add!, NewSSAValue, add_pending!,
2+
using Core.Compiler: count_added_node!, NewSSAValue, add_pending!,
33
StmtRange, BasicBlock
44

5+
# Re-named in https://github.com/JuliaLang/julia/pull/47051
6+
const add! = VERSION < v"1.9-" ? Core.Compiler.add! : Core.Compiler.add_inst!
7+
58
Base.length(c::Core.Compiler.NewNodeStream) = Core.Compiler.length(c)
69
Base.setindex!(i::Instruction, args...) = Core.Compiler.setindex!(i, args...)
710
Core.Compiler.BasicBlock(x::UnitRange) =

src/tangent.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function StructArrays.staticschema(::Type{<:TaylorBundle{N, B}}) where {N, B}
260260
Tuple{B, Vararg{Any, N}}
261261
end
262262

263-
function StructArrays.component(m::TaylorBundle{N, B}, i::Int) where {N, B, T}
263+
function StructArrays.component(m::TaylorBundle{N, B}, i::Int) where {N, B}
264264
i == 1 && return m.primal
265265
return m.coeffs[i - 1]
266266
end

0 commit comments

Comments
 (0)