Fix Documentation build: CanonicalMoments SymbolicsExt precompile failure on Symbolics 7 - #47
Merged
ChrisRackauckas merged 1 commit intoAug 26, 2026
Conversation
The docs build fails while precompiling `CanonicalMoments -> SymbolicsExt`,
which cascades into an OUQBase precompile failure, because the extension
relies on two things that no longer hold with Symbolics 7:
- `@register_array_symbolic` inspects each declared argument type, and
`AbstractVecOrMat{<:Real}` is a `UnionAll` wrapping a `Union`. Symbolics 7
reaches for `.parameters` on it, raising
`FieldError: type Union has no field parameters`. Declaring the argument as
`AbstractArray{<:Real}` keeps both the vector and matrix cases without
introducing a `Union`.
- `Symbolics.array_term` was removed in Symbolics 7, so the manual companion
matrix term construction cannot work. Registering
`CanonicalMoments._companion_matrix` instead lets the macro build the lazy
array term for symbolic inputs and fall through to the existing numeric
implementation otherwise.
Verified that the extension precompiles and that the symbolic support/weight
path round-trips against the numeric implementation on both Symbolics 6.29.2
and 7.36.0, and that `docs/make.jl` completes.
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Problem
The Documentation build fails before
makedocsis reached, while precompilingCanonicalMoments → SymbolicsExt:That failure cascades into
Failed to precompile OUQBase, sodocs/make.jldies at its firstusing.Root cause
#40 widened the
CanonicalMomentscompat entry toSymbolics = "6.29.2, 7.30".OUQBasealso allowsModelingToolkit = "9.69, 11.31", so the docs environment now resolves Symbolics 7 (7.36.0 / MTK 11.40.0 locally). Two things inlib/CanonicalMoments/ext/SymbolicsExt.jldo not survive that:@register_array_symbolicintrospects every declared argument type.AbstractVecOrMat{<:Real}is aUnionAllwhose body is aUnion, and Symbolics 7'sis_wrapped_array_eltypeunwraps theUnionAlland then reads.parameters, which aUniondoes not have. Hence theFieldError.Symbolics.array_termwas removed in Symbolics 7 (hence the undeclared-binding warning), so the hand-rolled companion matrix term in_companion_matrixcannot be constructed.Fix
EigvecWeightAlgregistration asAbstractArray{<:Real}. This still covers the vector and matrix cases thatAbstractVecOrMatwas there for, but is not aUnion, so the macro can introspect it. (RegisteringAbstractVectorandAbstractMatrixseparately is not an option: both expand to the same(AbstractMatrix, BasicSymbolic)method and trip "Method overwriting is not permitted during Module precompilation".)array_termconstruction and instead registerCanonicalMoments._companion_matrixitself with@register_array_symbolic. The macro builds the lazy array term for symbolic inputs and falls through to the existing numericSymTridiagonal(-B, sqrt.(C[2:end]))implementation otherwise, which is what the old code emulated by hand. This works unchanged on Symbolics 6 and 7, so no compat entry has to be narrowed.The now-unused
unwrap/wrap/array_termimports and theLinearAlgebradependency of the extension are removed along with the code that used them.Verification
docs/make.jlruns to completion locally (Julia 1.12.4, Symbolics 7.36.0, ModelingToolkit 11.40.0, SymbolicUtils 4.45.0), with only the pre-existingmissing_docswarnings thatwarnonlyalready tolerates.Runicreports no formatting diff for the changed file.Out of scope, but worth flagging
OUQBase's Core tests still error on Symbolics 7, for an unrelated reason inlib/OUQBase/src/operators.jl:SymbolicUtils 4 added the
::Type{T}method, sopromote_symtype(::𝔼_, x)needs to becomepromote_symtype(::𝔼_, ::Type{T}) where {T}. That code is not reached by the docs build, so I left it out of this PR to keep the change limited to the Documentation failure.Made with Cursor