-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
backport 1.10Change should be backported to the 1.10 releaseChange should be backported to the 1.10 releasecompiler:effectseffect analysiseffect analysis
Description
Reproducer:
module Zeros
export Zero
struct Zero end
end
module PositiveIntegers
module RecursiveStep
using ...Zeros
export recursive_step
function recursive_step(@nospecialize t::Type)
Union{Zero, t}
end
end
module UpperBounds
using ..RecursiveStep
abstract type A end
abstract type B{P <: recursive_step(A)} <: A end
abstract type C{P <: recursive_step(B)} <: B{P} end
end
const PositiveIntegerUpperBound = UpperBounds.A
const PositiveIntegerUpperBoundTighter = UpperBounds.C
using .RecursiveStep
export
natural_successor, natural_predecessor,
NonnegativeInteger, NonnegativeIntegerUpperBound,
PositiveInteger, PositiveIntegerUpperBound,
type_assert_nonnegative_integer, type_assert_positive_integer
struct PositiveInteger{
Predecessor <: recursive_step(PositiveIntegerUpperBoundTighter),
} <: PositiveIntegerUpperBoundTighter{Predecessor}
predecessor::Predecessor
global const NonnegativeInteger = recursive_step(PositiveInteger)
global const NonnegativeIntegerUpperBound = recursive_step(PositiveIntegerUpperBound)
global function natural_successor(p::P) where {P <: NonnegativeInteger}
r = new{P}(p)
type_assert_positive_integer(r)
end
end
function type_assert_nonnegative_integer(@nospecialize x::NonnegativeInteger)
x
end
function type_assert_positive_integer(@nospecialize x::PositiveInteger)
x
end
function natural_predecessor(@nospecialize o::PositiveInteger)
r = o.predecessor
type_assert_nonnegative_integer(r)
end
end
module IntegersGreaterThanOne
using ..PositiveIntegers
export IntegerGreaterThanOne, IntegerGreaterThanOneUpperBound
const IntegerGreaterThanOne = let t = PositiveInteger
t{P} where {P <: t}
end
const IntegerGreaterThanOneUpperBound = let t = PositiveIntegerUpperBound
PositiveIntegers.UpperBounds.B{P} where {P <: t}
end
end
module Utils
using ..Zeros, ..PositiveIntegers, ..IntegersGreaterThanOne
export minus_two, half_floor
function minus_two(@nospecialize m::IntegerGreaterThanOne)
natural_predecessor(natural_predecessor(m))
end
function half_floor(@nospecialize m::NonnegativeInteger)
ret = if m isa IntegerGreaterThanOneUpperBound
let n = minus_two(m), rec = @inline half_floor(n)
type_assert_positive_integer(natural_successor(rec))
end
else
Zero()
end
type_assert_nonnegative_integer(ret)
end
end
V1.10 works fine, on v1.11 and v1.12 this happens:
julia> include("/home/nsajko/tuple_sorting/reproducer.jl")
Main.Utils
julia> Base.infer_effects(Utils.half_floor) # OK
(+c,+e,!n,!t,+s,?m,+u,+o,+r)
julia> Base.infer_effects(Utils.half_floor) # ?!??
(!c,!e,!n,!t,!s,!m,!u,!o,!r)
julia> versioninfo()
Julia Version 1.12.0-DEV.1466
Commit 73b85cfc04d (2024-10-23 01:12 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
JULIA_NUM_PRECOMPILE_TASKS = 4
JULIA_PKG_PRECOMPILE_AUTO = 0
Metadata
Metadata
Assignees
Labels
backport 1.10Change should be backported to the 1.10 releaseChange should be backported to the 1.10 releasecompiler:effectseffect analysiseffect analysis