Repository navigation
TSLANG 215: Record<string, T>, unions of tuples (cast fills missing elements), rc/own leaks, own reads @owned - #1051
Merged
Merged
Conversation
…a mapped type of string keys) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elements throws), indexed at a common element; a missing tuple element is an error, not a silent failure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… own copies a tuple's strings for its array, union-of-shapes tests read the union's tag (no leaked box) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…les of elements, TSLANG_ISSUES measurements Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d literal given to a call, a union of tuples iterated and read at a run-time index Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s result excepted) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s own (a new value, not a part of what the call was given) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a shorter one lacks (user ruling); none to fill them with is a compile error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… by any object, keyof of a dictionary is string; verifier skips the fill tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Leftovers of 214 (TSLANG 215):
Record<string, T>, unions of tuples, three leaks, and-mm=ownnow reads@ownedas rc does. Two user rulings from 11-27 are implemented here.Fixed
Record<string, T>was an object with no fields, in every model. The literal given to it lost its fields,Object.keysgave none, andr["a"]read nothing.{ [key: string]: T }, a dictionary of T.{ [P in K]: T }of K = string (the default library's Record).[number, string] | [number, string, string]):undefinedthere.""for a string,0for a number,falsefor a boolean,undefinedwhere the type admits it.nullfor a string, a class, an interface or an array.x[1]at a constant index every member has,x[i]at a run-time index andfor (const e of x)now work. Before, they gave "access expression is not applicable".x.slice(1),join,forEach,map) and[...x]use the member the value holds. Before, they read the value as the first member, so a[0, "c"]joined as "0,c,null".x[1] = vstays refused, with a message that says why: the element is read out of a copy of the member.anybox, about 40 bytes a cast under rc and own. The union's own tag is read now.([i, s] as ...).slice(1),t.slice(1)of a tuple,[...x].cnt(...xs), and the default library'sjoin("".concat(...parts)).t.slice(1)oft: [number, string]) was refused. Its strings are now copied for the array.const. USER RULING 11-27: own reads rc's attributes the same way.s.toUpperCase()16 bytes,s.split()107,toFixed64,JSON.parseabout 800.@owned, the only rc-only attribute, in two places:OwnedReturnConsumptionPassgives back a result nothing takes.value.get("k").asString()still compiles.@lends, or a result typethis, such asJsonValue.getorArrayBuffer.__bytes) stays a borrow under own. Treating it as owned would free a value the object still holds. rc is unchanged.lib.tshas its mark inlib.d.ts. Calls through function values, callbacks and getters are flat too.Record<string, T>result type read in another function now has its members generated:Object.keys(f())failed with the default library.T extends Record<string, X>is met by an object of any fields.keyofof a dictionary isstring.Not done (recorded in TSLANG_ISSUES 215)
return <Long>x): "merged from several branches". Casting it where it is read, or into a local, works.for (const it of items) out[it] = 1) is still refused. Its drop facts need to name what is underthis.Checks
00tslang_issue_215JIT legs, run against a test already edited for the fill rule; after it, the 215, fill, dictionary, record and keyof tests pass (317), and so do all 8 ownership-verifier shards. The last full run was stopped so CI tests the final commit.Record<string, X>regressions (as a constraint, a result type, or underkeyof), fixed in the last commit.--opt=false): flat under own and rc for each case above.Tests:
00tslang_issue_215.ts(all models)test-{rc,own}-owned-declarations(the IR of@ownedand@lendscalls)tuple_union_cast_fill_error.tstuple_union_cast_fill_nonstrict.ts(--strict-null-checks=false, all models)🤖 Generated with Claude Code