Fix StackOverflowError in promote_type with Any (#94, #166)#199
Open
Fix StackOverflowError in promote_type with Any (#94, #166)#199
Conversation
Return Union{} instead of Any from promote_rule_constant when the
coefficient type is unspecified. Returning Any causes infinite
recursion in Base.promote_type because promote_rule returns Any from
one direction and the polynomial type from the other.
This fixes the StackOverflowError that occurs when Julia 1.13's @test
macro evaluates function arguments and creates Expr-typed values that
trigger type promotion with polynomial types.
https://claude.ai/code/session_01SGAgzkbRVNAL51y3Fo9fni
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.
Summary
Union{}instead ofAnyfrompromote_rule_constantwhen the coefficient type is unspecified (lines 63-64 ofsrc/promote.jl)Returning
Anycauses infinite recursion inBase.promote_typebecausepromote_rulereturnsAnyfrom one direction and the polynomial type from the other — this is the root cause of #94 and #166.This surfaces on Julia 1.13-beta3 because the
@testmacro now evaluates function arguments individually (JuliaLang/julia#57825), creatingExpr-typed values that trigger type promotion with polynomial types.The remaining julia-pre CI failures are in MultivariatePolynomials' test/commutative/comparison.jl where
eval_test_functioncreatesExprvalues that hitMethodError: no method matching zero(::Expr)— that needs to be fixed upstream in MP.Test plan
https://claude.ai/code/session_01SGAgzkbRVNAL51y3Fo9fni