Skip to content

Conversation

d-torrance
Copy link
Member

This fixes a recursion error which I think may have been introduced in #3845 (when texMath(Ring) was split off from texMath(HashTable)):

i1 : texMath HashTable
stdio:2:7:(3): error: recursion limit of 300 exceeded

The issue is that types are mutable hash tables, and the texMath method for mutable hash tables calls texMath on the class, which is itself a mutable hash table, causing the infinite recursion.

@d-torrance d-torrance requested a review from pzinn October 6, 2025 10:25
@pzinn
Copy link
Contributor

pzinn commented Oct 7, 2025

ah yes this is a strange bug. on my branch I have

texMath HashTable := H -> if H.?texMath then H.texMath else (
    if hasAttribute(H, ReverseDictionary) then texMath toString getAttribute(H, ReverseDictionary)
    else if isMutable H then texMathMutable H
    else texMath class H | texMath apply(sortByName pairs H, (k, v) -> k => v))

note the extra 2nd line.
not sure why this didn't make it in #3845.
I think this is a better fix...

@pzinn
Copy link
Contributor

pzinn commented Oct 7, 2025

more precisely, here's the diff:

199,209c223,226
< texMath HashTable := H -> (
<     if isMutable H then texMathMutable H
<     else texMath class H | texMath apply(sortByName pairs H, (k, v) -> k => v)
<     )
< 
< texMath RingFamily :=
< texMath Ring := R -> (
<     if R.?texMath then R.texMath
<     else if hasAttribute(R, ReverseDictionary) then texMath toString getAttribute(R, ReverseDictionary)
<     else (lookup(texMath,HashTable)) R -- should never happen
<     )
---
> texMath HashTable := H -> if H.?texMath then H.texMath else (
>     if hasAttribute(H, ReverseDictionary) then texMath toString getAttribute(H, ReverseDictionary)
>     else if isMutable H then texMathMutable H
>     else texMath class H | texMath apply(sortByName pairs H, (k, v) -> k => v))

not sure why I decided to split Ring/RingFamily from HashTable... I think it's better to reunite them.

Replace texMath(Ring) with more general texMath(MutableHashTable)
@d-torrance
Copy link
Member Author

I've pushed a new proposal, removing texMath(Ring) and replacing it with texMath(MutableHashTable). This also lets us simplify texMath(HashTable) since we can remove the isMutable check.

@d-torrance d-torrance merged commit dcc2421 into Macaulay2:development Oct 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants