Remove IfElse.jl dependency; use Base.ifelse#473
Merged
Conversation
IfElse.jl's `ifelse` is `const ifelse = Base.ifelse` on modern Julia (0.1.1), so the dependency is redundant: Symbolics registers a symbolic method on `Base.ifelse`, so `ifelse(sym_cond, a, b)` traces to a symbolic expression without IfElse. Removing IfElse also unblocks the strict Downgrade lane, which previously could resolve IfElse 0.1.0 (whose greedy `ifelse(args...) = Core.ifelse(args...)` broke symbolic conditions). - Replace `IfElse.ifelse(...)` call sites with bare `ifelse(...)`. - Drop every `using IfElse` / `import IfElse` line. - Remove IfElse from [deps] and [compat]. - In Blocks, the removed `import IfElse: ifelse` had brought `ifelse` into scope so the `Parameter` overloads in sources.jl extended it. Replace with `import Base: ifelse` so those overloads extend `Base.ifelse` instead of creating a new `Blocks.ifelse` binding that would shadow the symbolic method. - Drop the now-stale Downgrade.yml comment referencing the fntype regression. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
ChrisRackauckas-Claude
force-pushed
the
fix-red-lane
branch
from
July 5, 2026 06:19
2823079 to
2fd0725
Compare
ChrisRackauckas
marked this pull request as ready for review
July 5, 2026 07:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas.
Problem
The strict Downgrade lane (
allow_reresolve=false) fails because the resolver was allowed to pickIfElse0.1.0, whose greedy varargs methodintercepts symbolic
Numconditions and forwards toCore.ifelse(which requires aBool), throwingTypeError: non-boolean (Num) used in boolean contextat symbolic source constructors such asSine(src/Blocks/sources.jl).Fix
Remove the
IfElse.jldependency entirely and rely onBase.ifelse. On modern Julia,IfElse.ifelseisconst ifelse = Base.ifelse, and Symbolics registers a symbolic method onBase.ifelse, soifelse(sym_cond, a, b)still builds a symbolicifelse(...)expression rather than eagerly evaluating.IfElse.ifelse(...)call sites with bareifelse(...).using IfElse/import IfElseline.IfElsefrom[deps]and[compat].src/Blocks/Blocks.jl: the removed line wasimport IfElse: ifelse, which broughtifelseinto module scope so theifelse(::Bool, ::Parameter, ...)overloads insources.jlextended it. A bare removal makes those method definitions create a newBlocks.ifelsebinding that shadowsBase.ifelsefor the whole module, so the symbolicBase.ifelsemethod is no longer visible andSine/Step/Ramp/… fail to build withMethodError: no method matching ifelse(::Num, …). Replaced withimport Base: ifelseso theParameteroverloads extendBase.ifelseand the symbolic method stays in scope.Downgrade.ymlcomment referencing the fntype regression.Validation (local, Julia 1.12)
ModelingToolkitStandardLibrary.Blocks.ifelse === Base.ifelseistrue.ifelse(t % T > duty_cycle*T, 1, 0)(DigitalPulse/DigitalPincomparator patterns) buildSymbolicUtils.BasicSymbolicifelse(...)nodes — no eager evaluation.Sine(andSquare/Step/Ramp/Triangular/ExpSine) build successfully after theimport Base: ifelsefix (they fail with a bare removal — confirmed).test/analog.jlfull pass — exercisesSquare/Sine/Triangularplus NMOS/PMOS/NPN/PNP transistors and mosfets which useifelse;test/digital.jl;test/sources.jl;test/isothermal_compressible.jl;test/thermal.jl). No new failures. The pre-existing errors (fntype_X_Yinterpolation errors insources.jl,ValveDomainErrorinisothermal_compressible.jl,ExtraVariablesSystemExceptioninthermal.jl) reproduce byte-identically on unmodifiedmainand are unrelated to this change (existing MTK 11 / DataInterpolations incompatibilities in the dev depot).julia-downgrade-compatv2.6.1downgrade.jl) now reports "Successfully resolved minimal versions for . (with extras)". IfElse remains only as a transitive dependency ofStatic/CPUSummary/etc.; MTKStandardLibrary no longer depends on it directly, so the resolver is no longer exposed to IfElse'sifelsemethod for the package's own symbolic code.🤖 Generated with Claude Code