Skip to content

Fix factorial forward references by deferring UInt view return types - #486

Open
jmh530 wants to merge 1 commit into
libmir:masterfrom
jmh530:codex/factorial-forward-reference
Open

jmh530 wants to merge 1 commit into
libmir:masterfrom
jmh530:codex/factorial-forward-reference

Conversation

@jmh530

@jmh530 jmh530 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

A standalone factorial(3) call can fail with an Fp!128 forward-reference error, including when reached through mir-stat's integer-shape gamma PDF. Inferring the return types of both UInt.view overloads defers the BigUIntView instantiation that exposes this cycle. The method bodies, concrete view types, qualifiers, and attributes remain unchanged.

Add mutable/const view tests and a separate factorial regression executable. The standalone caller is important: prior bignum instantiations in the normal library test suite can mask the failure. Run it in the existing Windows, Linux, and macOS CI jobs.

Validation:

  • Confirmed the standalone DUB regression fails before the fix and passes afterward with Windows DMD 2.113 and LDC 1.43.
  • LDC bignum test configuration: 12 modules passed.
  • DMD general/numeric test configuration: 51 modules passed.
  • The same return-type change was also checked in isolated Linux DMD 2.112 and LDC 1.36 reproductions during investigation; hosted CI will exercise the submitted workflow.

Fixes #485.

AI-Assisted-By: Codex (GPT-6 Astra Medium)

Infer the return types of both UInt.view overloads to defer BigUIntView
instantiation while Fp and UInt are being resolved. Preserve the view
bodies, concrete return types, qualifiers, and function attributes.

Add mutable and const view checks and a standalone factorial caller.
Run the caller in the existing CI jobs so unrelated bignum instantiations
cannot mask the regression.

Fixes libmir#485.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
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.

factorial fails with an Fp forward reference; deferring UInt.view return types fixes compilation

1 participant