fix: raise MAX_GENERIC_INSTANCES from 100 to 1000 to support Drizzle/Zod inference - #219
Open
techfreaque wants to merge 1 commit into
Open
fix: raise MAX_GENERIC_INSTANCES from 100 to 1000 to support Drizzle/Zod inference#219techfreaque wants to merge 1 commit into
techfreaque wants to merge 1 commit into
Conversation
The cap exists to detect POLYMORPHIC recursion (`f<T>` calling `f<T[]>`) that would diverge forever. A real-world program with deeply generic utility types (Drizzle ORM, Zod, tRPC) exhausts 100 instances during normal non-recursive specialization — the compiler stops mid-lowering and emits a diagnostic instead of a binary. 1000 is still a hard cap against runaway polymorphic recursion; it is simply high enough that a ~600-file application with heavy generic usage doesn't hit it spuriously.
Contributor
|
@techfreaque is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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
MAX_GENERIC_INSTANCES(the cap that detects polymorphic recursion) was set to 100. Real-world TypeScript codebases using Drizzle ORM, Zod, and similar heavily-generic libraries routinely exceed this limit during type inference, producing spurious SC1000 (max instantiation depth) errors on valid programs.Fix
lower-calls.ts:MAX_GENERIC_INSTANCESraised from100to1000.The cap still serves its purpose — infinite polymorphic recursion hits 1000 just as reliably as it hit 100. The difference is that legitimate deep generic stacks (Drizzle's
select()return type, Zod's.parse()inference) now pass through without false positives.Verification
A schema with 30+ Drizzle table joins and deep Zod inference compiles without SC1000. Artificially recursive types are still caught.
packages/compilerbuilds clean.