Repository navigation
[experiment] edge-local relation depth cutoffs - #65704
Closed
Jake Bailey (jakebailey) wants to merge 79 commits into
Closed
Jake Bailey (jakebailey) wants to merge 79 commits into
Jake Bailey (jakebailey) wants to merge 79 commits into
Conversation
These tests are added before the changes they cover, so that each change shows in their baselines.
isDeeplyNestedType counts only occurrences of a recursion identity newer than the previous one, using type ids for "newer", so whether a comparison gave up as deeply nested depended on which code had been checked before. It now compares generations: a type's generation is one more than the highest generation of the types it was built from. An occurrence of a higher generation was built by the recursion and counts. One of a lower generation is a nested type argument or member, and counts only if it is a conditional type, an indexed access, or another type that evaluating a step can make with fewer layers, and the previous occurrence was not built from it. A copy of the previous union or intersection with the same constituents, such as one that lost its alias, is the same level of nesting (seen in BlockNote and type-fest), unless both have aliases, whose type arguments can keep growing while the constituents stay the same (seen in tambo). Comparing the RpcStub types of capnweb, which form a variance circularity, recurses through deeply nested instantiations, and reached the instantiation limit before this (seen in cloudflare-os). Fixes 17873 Fixes 34099 Fixes 60453 Fixes 64757
CompareTypes orders the constituents of unions, and so printed types,
union deduplication, and everything derived from them. Many types it
cannot tell apart fell through to the type id, which follows creation
order, so these results depended on which code had been checked before.
Most such ties were copies: checking the same expression again
(inference passes, overload resolution, contextual re-checks) created a
new type with identical content every time.
Types that are the same by content are now interned, so the same
inputs yield the same type whenever and however often they are
computed:
- object literal types;
- spread results and the property symbols they synthesize;
- widened, regular, and padded copies of object literals;
- object rest types;
- types implied by binding patterns;
- intersections with the same constituents, flags, and alias.
Interned object types are keyed by their members in table order, so
spreads such as { ...a, ...b } and { ...b, ...a } stay distinct and
each keeps its own property order.
Types that remain distinct are ordered by how they were derived:
- type parameters sharing a symbol (tuple elements, clones made for
signature and mapped type instantiation, distributive and
restrictive copies) by the kind of copy, then by their origin and
the instantiation they were made for;
- fresh and regular literal types, array literal types after the
references they were cloned from, and object literal copies by the
flags they were created with;
- object literal, rest, and binding pattern types by the declarations
and names of their members;
- tuple targets by their label declarations;
- indexed access types by their access flags.
The pseudo-type printer reused the declared type of an inferred
property assignment when the expression's widened type matched, but
that type is widened without the context of its object literal and
can differ from the real one. It is now reused only when equivalent.
Interning lets a comparison reuse a cached relation result that would
otherwise have been computed again for a fresh copy of a type. A result
computed while the return type of a signature still being resolved
reads as any holds only until that return type is known, so it is no
longer cached. Otherwise, relating the arguments of a call whose return
type is being inferred from them caches a success, and the call no
longer reports that no overload matches (seen in lexical).
compareNodes ordered nodes of a file by position only, so distinct nodes starting together, such as a source file and its first statement or adjacent missing nodes, compared as equal, and sorting them kept whichever order they were found in. They are now ordered as they appear in the tree, so that a node compares equal only to itself.
Symbols the checker derives from a declared one, such as the members of mapped types or readonly copies of object literal properties, share its declaration and name, so compareSymbols ordered them by symbol id. Symbol ids are assigned in the order symbols are first used, which depends on which code was checked before. They are now ordered by whether they are transient and by their check flags first.
Object types derived from others, such as spreads and widened copies,
are interned by their member symbols in member table order and by
their index signatures. Object literal types are interned by the
flags, name types, and types of their members. Both were ordered only
by the declarations, optionality, and types of their members. A spread
over a union can make types that differ only in the order of their
members, such as { ...a, ...b } and { ...b, ...a }, and these were left
to the type id. Widened copies of types implied by binding patterns
have no symbol and were not ordered by their members at all.
They are now ordered by everything they are interned by, the member
symbols last, so that a type compares equal only to itself.
The instantiations of a conditional type are cached on its root, but distributive and tail-recursive evaluation create deferred conditional types without that cache, so the same deferred conditional type, with the same root, mappings, and alias, could be created more than once. Such copies can be told apart only by type id, which follows the order in which code was checked. Deferred conditional types are now interned by their root, the content of their mapper, and their alias. Those made for a constraint stay apart from the others, as the instantiation caches of a conditional type already keep them: evaluating a conditional type for a constraint can include its true branch where evaluating it otherwise would not. Sharing the deferred types made for one with the other reused the comparisons reached from them, and checking calls with SetOptional of generic keys then exceeded the instantiation depth limit (seen in type-fest). Instantiations of InferData and UnpackKeyValue, whose recursion is bounded, are no longer reported as infinitely circular when inferred through a closure (boundedRecursiveTypeInferredThroughClosure).
Symbols the checker makes from others, such as the properties a spread merges or copies, the members of mapped types, instantiated symbols, and the copies of a module symbol made for each import of it, share the declaration, name, and flags of the symbol they are made from, and were ordered by symbol id, which follows the order in which symbols are first used. They are now ordered by the symbols, types, and imports they are made from, which are recorded when they are created. The symbols made for unresolved names share their name, and are ordered by the unresolved names that qualify them, as Bidi.Event and Protocol.Cdp.Event are when neither module is found (seen in puppeteer and DefinitelyTyped).
The type of a module with a synthetic default import is a spread under a type literal symbol, and widening it makes a copy with the same symbol. Neither is an object literal, so nothing but their type ids distinguished them. Unnamed object types are now also ordered by the flags recording how they were created.
Instantiations of distinct object literal types made by the same declaration, such as the copies a call makes when it infers from an argument twice, were ordered only by their mappers. Instantiations with mappers of the same content then compared as equal and fell back to the type id (seen in t3code). They are now ordered by the type they instantiate first.
Inferring from string literals to keyof T infers to T from an object type with an any-typed property per literal, which was made anew every time, so inferring from the same literals twice yielded types that could be told apart only by type id (seen in tanstack-router). They are now interned by the literals and whether the source includes string.
The members of a type implied by a binding pattern have no declarations, so types implied by two patterns with the same names, and their widened copies, could be told apart only by their member symbols, which were ordered by symbol id (seen in vscode). Each member now records the binding element declaring it, as TypeScript's checker does, and is ordered by that element. Types that record the pattern implying them are also ordered by that pattern before their members.
compareTypeMappers compared simple, array, and merged mappers by their mappings and treated all others as equal. Symbols instantiated through composite mappers with different mappings then compared as equal and fell back to the symbol id (seen in sentry). Composite mappers are now compared by the two mappers they compose, and deferred conditional types are interned by them too.
Spreading a union of one object type and empty objects makes an object type with the properties of the object type made optional. A new type with new properties was made every time, so spreading the same union twice yielded types that could be told apart only by their properties' symbol ids (seen in tanstack-router). They are now interned by the object type and whether the spread is readonly.
Type ids follow the order in which types are created, and symbol ids the order in which symbols are first used, both of which depend on which code was checked before. Ordering by them made union order, printed types, and everything derived from them depend on check order. Types and symbols are now ordered by their content, so that a value compares equal only to itself and a sorted list of them is a set by identity. Reaching the id fallback means two distinct values cannot be told apart, and is now an assertion failure, except for the types created with the checker, such as the intrinsic types and the variance markers, whose order of creation is fixed.
checkAssertion runs in several check modes, such as when a call is first checked without its context sensitive arguments, and each run overwrote the operand type kept for the deferred comparability check. That check used whichever was stored last, so its result depended on the order in which the assertion was checked. The deferred check now uses the cached normal type of the operand. The assertion itself only needs the operand type for `as const`, and the operand of a non-const assertion is contextually typed by the asserted type alone, so in any check mode the assertion computes the cached type the deferred check will read, with inference for an enclosing call hidden from the operand. This is the result the deferred check would produce on its own, and checks each operand once rather than again with fresh flow analysis in the deferred check.
The type of a destructured parameter's binding elements depended on
whether the parameter's type happened to be cached already. For
example, in non-strict mode
(({ [a()?.d]: c = "" }) => {})();
reported TS2537 when 'c' was queried before the IIFE call resolved
the parameter (its declared type is the undefined widening type),
but not otherwise. Conversely, in
f7({ a: {} });
function f7({ a: { x = 0, y = 0 } } = { a: {} }) {}
calling f7 first made 'x' and 'y' errors of type any.
Make the choice depend only on the declaration. Parameters of
context-sensitive functions take their type from contextual
assignment, so ask for the parameter's type. Everything else uses
the type derived from the declaration, as it did when nothing was
cached. Asking for the parameter's type unconditionally instead
introduces circularities in patterns whose initializers reference
sibling elements.
A context-sensitive function is typed in parts: the enclosing call
assigns its parameters their contextual types, completes its signature
with the type parameters of a generic contextual signature, and checks
it. Queries that reached the function before or during those steps saw
it incomplete and cached the types they derived from it.
The first query of such a parameter returned the type it computed
itself from the final signature, while every later query returned the
type the enclosing call assigned. In
declare function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
the last 'x' was number when the call was checked first, but any when
'x' was queried first. The assigned type is now returned whenever one
exists, as the original comment intended.
Type aliases in the body read the signature's type parameters as outer
type parameters, so querying such an alias first resolved its
conditional types eagerly. In
declare function f(fun: <T>(t: T) => void): void
f(function self(t) {
const s = self;
type P = Parameters<typeof s>;
});
P was [t: unknown] when the call was checked first, but [t: T] when P
was asked for first. Assigning the contextual parameter types, which
completes the signature, is now split from the rest of the contextual
check, and every way to obtain the signature requests it: the type of
the function's symbol, before anything resolves its members, and the
signature of its declaration. Contextual typing can reach the
enclosing call while the signature is being created, so the signature
created there is kept rather than replacing the one that was
contextually typed. In JavaScript, a @type tag on the function still
supplies the signature whose parameters are assigned, as it supplies
the signature of the function's symbol (seen in webpack).
When resolving a function expression's members reached the function
again through its enclosing call, the contextual check saw an empty
signature list and gave up, yet left the node marked as checked, so
implicit any errors could be lost depending on which query got there
first. The deferred function check now requests the contextual check,
so it is performed at least once.
Fixes 42175
Generic calls nested in the arguments of other generic calls, or in context-sensitive functions passed to them, depend on the enclosing call for their contextual type and parameter types, and the enclosing call infers from them in turn. When the inner call was queried first, it was already marked as resolving by the time its contextual type resolved the enclosing call, so the enclosing inference saw a placeholder and both calls cached results that a check in source order never produces. Computing the contextual type of a call nested in an argument of an enclosing call before resolving it resolves the enclosing call first, as source order does. Other contexts are not resolved ahead of time, since computing them may evaluate expressions that checking does not, such as the target of a destructuring assignment. Resolving a call's signature can also be requested while checking one of its arguments. Errors that resolution reports at the current node, such as an instantiation depth error, were located at whichever node asked first, so checking an argument ahead of its call moved the error onto the argument. Resolution is now located at the call. For 55640
Asking for the symbol of a property access that hits an index signature stored the index symbol as the access's resolved symbol. Checking a delete expression reads that link to decide whether the operand must be optional, so a prior symbol query turned `delete a.x` on an index signature into an error that a plain check does not report. The type of the index symbol at such an access, which hovers show, now looks the index symbol up again rather than reading it from links. A single signature type produced by higher order inference is instantiated with the full mapper combined in, since its signature can reference type parameters other than the outer type parameters of its declaration. The instantiation cache was keyed only by the mapped outer type parameters, so two instantiations differing in another type parameter (here the this type) shared whichever result was computed first, and checking `outer.log` gave it the type of `inner.log`. Such instantiations are no longer cached.
Explaining why a name failed to resolve looks up other symbols, for example to find a spelling suggestion, and that can resolve aliases. When the failed name was the target of an alias, the suggestion lookup re-entered the alias being resolved, or skipped it, depending on which aliases were already in progress. In declarationEmitUnknownImport that decided whether two "Circular definition of import alias" errors were reported: they appeared when the import was checked first, and not when the export specifier was resolved first. Defer the explanation until no resolution is in progress, so it only observes finished results. The circularity errors that were artifacts of the suggestion lookup are no longer reported.
When one reference hit the flow analysis depth limit, flow analysis was disabled for every later reference in the same function or module body, so the type of a reference depended on whether another reference in the body had been analyzed before it. Each reference now gives up only when its own analysis hits the limit. Shared flow node results are cached for the duration of one flow analysis, including incomplete results computed under a loop back edge. Once that loop's back edge has been exited and the loop label has a complete type, they are stale. Reusing them made a reference's type depend on which reference was analyzed first: in exhaustiveSwitchCheckCircularity, querying the reference inside the loop before the switch expression produced `never` instead of "bbb". An incomplete shared result is now reused only while the loop that was innermost when it was computed is still being analyzed.
A computed property name stored a placeholder type while its expression
was checked, and returned the placeholder when re-entered. That kept the
cycle off the resolution stack, so the computations in between did not
fail, and the placeholder `{}` escaped into messages when checking
entered through the property name, while `any` did when it entered
through the variable it references. In blockScopedBindingUsedBeforeDef,
the error read "Type '{}' cannot be used as an index type" or "Type
'any' ..." depending on which of them was checked first.
Resolve computed property names on the resolution stack, failing with
the error type on re-entry like other circular resolutions.
A relation that succeeds while an outer comparison is still in progress has only been shown to hold under the outer comparison's assumption. Caching it globally made later lookups depend on which comparison happened to run first. The same was true for results cut short by depth limits measured against outer resolutions. Each result now tracks the lowest resolution it depends on and whether it was truncated. Results are cached globally only when the comparison that introduced their assumptions completes, and truncated results only at their own head. Failures remain cached immediately, since assumptions only ever make a relation more likely to succeed. A comparison that only relates by assuming comparisons within it is reported as related once it completes, whether it is computed or read from the cache. Comparisons of types referencing constrained type parameters are considered related while the same comparison with unconstrained type parameters is in progress, since constraints only make more types related. A completed comparison found to succeed now counts the same way. That only went unnoticed because completed comparisons used to stay in progress until the outermost one completed; without it, relating structurally identical generic interfaces creates ten times the types.
Instantiating a signature copies a parameter unless the parameter's type has already been resolved, so whether the parameter in a signature's printed scope is the declared one depends on the types checked before. Both name the same declaration, so treating only the declared one as the same reference made printing a reused annotation depend on check order.
Computing the values of an enum's members type-checked each computed initializer to report one that is not a number. The initializer may refer to the enum itself, whose type then reads member values that are still being computed, so the enum's type depended on whether its values were first computed by checking it or by asking for its type. The values do not depend on the initializer's type, so the check now happens when the member is checked, as for any other error in an initializer.
Instantiating a symbol returned the symbol itself if its type was
already resolved and could not contain type variables, and an
instantiated symbol otherwise. Which one a member of an instantiated
type is then depended on whether its declared type had been resolved
first, which shows wherever symbols are displayed: hovering over the
same property could show A<T>.x or A<"a">.x.
Always instantiating would also change types. Instantiating an
instantiated symbol starts over from its target with the mappers
combined, and that can evaluate differently than instantiating twice:
for E := {}, E['V'][K] becomes unknown, but with K := never as well it
becomes never, rejecting arguments that the shortcut accepted. So an
instantiation of a symbol whose types have nothing left to instantiate
keeps those types.
Declaration emit marks the declarations it depends on as visible, such as those an export assignment names. Whether a declaration is visible was cached together with those marks, so a declaration whose visibility was asked before emit marked its container, as hovering over a use of it does, stayed invisible, and emit left it out. Caching only the visibility the rules of a declaration give, and applying the marks when asked, gives the same answer whenever emit marks them.
The node builder resolves names to decide whether it can reuse a type node written in the source, which marked them referenced. Printing a type, as hovering does, then hid unused declaration errors that checking alone reports. Fixes 65616
Resolving the name of a JSDoc link, as hovering over a documented declaration does, checks it as an expression, which marked the imports it names as referenced. Emit then kept imports that checking alone elides.
A checker's memos are not its only state: it also holds the state of the computations in progress, such as the contextual types pushed for the nodes being checked, the resolutions on the stack, and the cycles being resolved. The next request reads anything a request leaves there, so none of it may outlast the request that set it. Every field of Checker is now either listed as the state of the computations in progress, which the test harness checks is at rest after every request it makes, or listed with the reason it is not, as the fields of the memo store and links already are. A few fields kept indices or flags after the computation using them finished, which nothing read: the lowest cycle head observed, the cycle flag of errors collected at the current node, the start of a circularity, of a reverse mapping and of a depth limit. They are now left at rest too.
When a variance measurement reaches a type whose measurement is in progress, the results cached until the outermost measurement finishes may be discarded, in case the measurement did not start at the canonical entry of its circularity. Until then, checking switched to recording: storing the effects of each result to apply later, and accounting for them on every read of a cached result. Few measurements are ever discarded, a handful per project, but recording roughly doubles the cost of the work done in the meantime, and each checker measures the shared types again, so with several checkers it accounts for most of the extra time these changes cost on xstate. So checking keeps applying effects during a variance cycle, except those that discarding the measurement would have to take back: errors, suggestions and deferred diagnostics are held until nothing can discard them, and dropped with the results if the measurement is.
Every memoized computation records its key as in progress and removes it when it finishes, so that re-entering it is caught as a cycle. Nearly every lookup finds nothing, yet the hash table made each computation pay for an insertion and a deletion that shifts probe sequences. Counting keys per slot makes the common case one load and one increment; the rare hit searches the resolution stack, which already holds the keys.
Each memo map kept its own record of the entries being computed: their keys, where on the resolution stack each was, and, once there were many, a count of each key. The checker already counts every other computation in progress and finds it on the resolution stack, so map entries are now counted with the rest by a hash of the map and key, and found on the resolution stack when the count says one may be in progress. A map keeps only the keys themselves, which a resolution has no room for.
…ested Finding a computation in progress searched the whole resolution stack whenever its slot of the resolving table was taken, and marking the computations that read an incomplete result walked the stack above it. With thousands of computations in progress, as in an instantiation that runs away, nearly every slot is taken, so both cost time proportional to the depth on every step, and nesting deeply took quadratic time. Only the computations a search can find, those of memo cells counted as in progress, are linked from their slots. A computation re-entering one in progress runs again without being counted, and linking it as well let a runaway re-entry of one key build a chain that every search for the key walked to the end (seen in 63040).
The limit on the depth of the whole instantiation stack failed an instantiation at whatever depth the stack reached, which depends on how much of what it needed was cached before, so whether a finite but deep instantiation failed depended on the order types were checked in. Caching only ever shortens the stack, so an instantiation that would stay below a limit computed from scratch stays below it in any order. The limit is now a guard against runaway instantiations, far above any finite one in real code (the deepest measured, in arktype's tests, nests 189 instantiations computed from scratch), while the limit on each computation still reports deep ones. An instantiation reaching the guard fails as a whole wherever it is computed or reused, so an infinite one fails the same way in any order.
A cycle that passes through a member table in progress is computed again as if the table had been entered first, with everything below the table hidden. The table's own memoized computation sits just below its type resolution, so it was hidden too, and reading the table then failed the recomputation instead of reading the table. Which member of such a cycle failed then depended on where the cycle was entered: a type alias read through an index signature was circular when queried first, and a parameter typed through a class's base was circular when its class was checked first. Fixes 64998 For 61721
A cycle yield recomputes a member of the cycle with the computations in progress hidden. Reading a member table being resolved below the yield failed the recomputation, since the table it would see is whatever part of it has been published. A table that has published nothing is instead resolved again from scratch inside the yield, so there is nothing incomplete to read, and failing there reported a circularity for a property only when its class was checked before its type was queried. Fixes 61711
A variance measurement must give the same variances wherever it is first requested. The outermost measurement hid the type resolutions in progress below it, but memoized computations in progress stayed visible. When a query reached the return type of a method first, the measurement of its class re-entered the subtype reduction of that return type in progress below, treated it as a cycle and discarded the variances and the reduced type, so the method's return type depended on whether the class or the method was checked first. The outermost measurement is now a cycle yield, which hides every computation in progress below it, together with the contextual types, inference contexts and depth limits they entered.
When a qualified name used as a type does not resolve, the error
suggests typeof if the name resolves as a value, which needs the type
of the value its first identifier refers to. In
declare const n: n.T;
declare namespace n {}
that type is the annotation being resolved. Checking the annotation
first made it the head of the cycle, and the missing member it reports
was dropped along with the other results computed from the incomplete
annotation, so it was reported only when the type of n was queried
first. The type of a value used within its own declaration can depend
on the name being resolved, so no suggestion is made there, and the
missing member is reported in every order, without a circularity error.
(seen in 18163)
Reaching the limit on the instantiation stack failed every
instantiation in progress. A computation that resolves part of a type
whenever it is first needed, like the element type of a deferred array
type, is reached inside an instantiation or not depending on who needs
it first, so whether the instantiation needing it failed as a whole
depended on order. In
type A = A[];
const r = ([] as A).flat(Infinity);
r was any[] when the element type of A was resolved first, but any when
the call was checked first. Reaching the limit now fails only the
instantiations in progress in the innermost computation other than of a
cached instantiation, which fail the same way wherever the computation
is reached, so r is any[] in every order, as in TypeScript 6. A result
carrying the error no longer fails an instantiation reading it, as
computing it there would fail only within it.
Inside a cycle in progress, the innermost such computation can be one
re-entered just below the limit, whose own instantiations are finite.
Failing only it let the rest of the cycle go on at the limit, failing
computations that are finite and taking exponential time on recursions
with two branches. The computation that fails is now the one at the
head of the cycle, as the results computed in a cycle are kept or
discarded together.
A conditional type instantiation already known to fail was cached as
the error type before its failure was reported, so the instantiations
reusing it reported nothing and failed nothing. It now ends as other
instantiations do, and no instantiation known to fail is cached (seen
in fuzzing instantiationStackLimitCheckOrder and
recursiveConditionalCrash4).
For 49280
A base constraint keeps how deep its own walk went, so that a walk reusing it can tell whether computing it again there would give up. Comparisons are about to keep the same kind of record for their cached failures, so the record becomes a type of its own, a height, with the checks both need. The multiplication spreading the bits of a key over the high bits, which several tables and filters index by, is likewise written once.
Whether a comparison is too complex depended on how many of the results it needs were cached by comparisons made before it, so the same assignment could be an error in one check order and not another. Charge each reused result, once per comparison, the results that computing it cached, and count a comparison only too complex for those charges again with no result cached, which decides it exactly. The charge is kept in the spare upper bits of each cached result. A map of charges kept apart from the results held an entry for about half of them, which raised memory use by more than half (seen in 63854).
A cycle of interfaces extending each other kept different base types depending on which interface's base types were resolved first: the one entered first lost its base, and the others kept theirs. Asking for the members of one interface before checking the declarations could leave another without the properties it inherits. Resolve such a cycle from the class or interface declared first, as cycles through the types of symbols and the return types of signatures already are. Resolving the cycle's first member may resolve the base types the cycle re-entered, which are then kept, and a computation of base types resumed after the cycle resolved them keeps that result rather than adding its own.
The declared members of a class or interface are marked resolved before their index signatures are, as the types of those may refer back to the type. Resolving the members of the type while its declared members were still in progress, as checking the inherited properties of an interface with several bases does, or as resolving the members of its reference with its this type does, read the declared members without noticing the re-entry. The members were then resolved for good without the index signature, and keyof the type cached without it. Both keyof the type and whether its index signature existed depended on whether the type was checked before its members were otherwise needed, and so, with several checkers, on how files were assigned to them. Re-entering the declared members is a cycle like re-entering any other computation in progress, so results derived from the incomplete members are computed again once they are complete. Fixes 65543
An error that computing a cached result reports at the node being checked is reported at every node whose check reaches the result, as it would be had that node been checked first. A union type and its first constituent start at the same position, and both reach the result of resolving the constituent, so such an error was reported twice at one position, over spans of different lengths that are not deduplicated. The error is reported at the outermost type node starting where the node being checked starts. (seen in 64384)
Holding a check's effects during variance cycles leaves results with effects still to replay, and a few keep them for long, for example when the only read that would replay them was discarded with a variance measurement. While any result had pending effects, every read of a cached result took the slow path that looks for them, so a single one slowed all the checking after it (seen in xstate). The keys of results given pending effects are now kept in a filter, and a read takes the slow path only for a key that may have them.
Candidate selection (discriminants, strict arity, inference of generic signatures) can make a comparison fail because an outer comparison in progress is assumed related. The new namespaces of relationCycleNonMonotoneCheckOrder compare such an outer pair first, so that the failure computed under the assumption is the one cached, and its baselines differ between check orders. The other tests cover cases that a fix for this has to handle: a cycle whose first comparison fails, a cycle compared again from a member that finds a lesser member, relaters taken from the pool while a cycle is compared again, a cycle compared again while a superseded variance measurement is in progress, and assumptions on comparisons deeper than 64 levels. Their baselines agree in every check order.
A failure was cached as soon as it was computed, on the grounds that what fails under assumptions also fails without them. Candidate selection (discriminants, strict arity, inference of generic signatures) breaks that: assuming an outer comparison in progress related can select a candidate that then fails, so a failure computed under the assumption can be a success when compared on its own. Which of the two was cached depended on which comparison was reached first, and so on check order. A cycle with such a negative dependency can also have no answer that is the same from every entry point. A result now carries the comparisons in progress that it assumed, as a mask of their depths, and failures are held with successes until the comparisons they assumed complete. Comparisons from depth 63 on share the last bit, which only the comparison at depth 63 clears, so a result assuming any of them stays provisional until then and keeps the dependency. A refuted assumption discards only the results that depended on it, and failures that depend on no comparison in progress are cached as before. A cycle that fails at its head, or that holds a failure, is answered as if its least member were compared first: that member is compared from scratch in a relater of its own, which caches the results, and the head is compared again. The guard against comparing a member this way twice holds only the members compared this way, so a member found to be less while comparing again moves the entry point again. The relater keeps no guard storage in the pool, since the relater that lent it still uses it, and it continues the outermost comparison, so that a superseded variance measurement stops it as it stops the rest. Comparing the head again reports only its own reliability flags. relationCycleNonMonotoneCheckOrder now agrees in every check order. In relationCycleHeadFailureCheckOrder and relationCycleRestartPoolCheckOrder, the answer of the cycle changes alike in every order, to the one from its least member. inferFromTypeArgumentsNoInfiniteRecursion no longer reports TS2589. Relating its recursive alias to a variance marker unrolls a level per comparison until a depth cut-off answers Maybe; a failure enclosing that Maybe used to discard it, so the same pair was compared from scratch deeper in the walk and unrolled further, until instantiation reached its depth limit. A failure now discards only the results that assumed it, so the Maybe answers the pair. The error depended on check order as well (checking the type of R first reported a second one), and TypeScript 6.0 reports none.
Member
Author
|
TypeScript Bot (@typescript-bot) test it |
Contributor
Contributor
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
|
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. There were interesting changes: Branch only errors:
|
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.
for testing