Repository navigation
-mm=own: array entries, and the Array<T> class holds shared elements - #50
Merged
Merged
Conversation
reverse reads the element it swaps into a `let`, as sort's `temp` did: a `const` borrows the slot overwritten next. sort no longer assigns its optional comparator a default - a callback parameter that is assigned is one -mm=own knows nothing about, so a call of it with two elements was a use of them after a call that may release them; it gives a selectionSort helper the comparator or the default. Needs the compiler's copy of a string read out of a parameter the result borrows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…], a[i]]` The compiler's exchange of two places (spec 42) moves nothing in any model, where a swap through a local gave an object element a second owner under -mm=own. reverse over class instances now passes under own (array_reverse_class). sort over class instances (array_sort_class) is `// not own`: its comparison is handed on to selectionSort through a parameter, which has no callback facts yet. Needs the compiler's `ts.Swap`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sort gives its optional comparison on to selectionSort, and a callback given on through a parameter now keeps the facts of the functions passed for it (compiler spec 43), so array_sort_class is no longer `// not own`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/generics/lib.generics.ts
- entries() reads the element into the state before the yield. Own does not follow a tuple made from a borrow inside the yield itself yet. - class Array<T> is @SharedElements, as Map and Set are: concat, fill and slice copy elements, and an object has one owner, so an object goes in as Shared<T>. Its iterators say @borrows("this"), as T[]'s do. filter2 hands back T[]'s generator; as a generator itself, it returned that generator as its done value. concat no longer spreads other into a rest argument, which under own would move the arrays. - array_class_splice (an Array<Item>) is marked "not own". Needs the compiler's own-defaultlib-batch for new Array<number>() (a constructor parameter with a default) and the other own fixes. 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.
Depends on ASDAlexander77/TypeScriptCompiler#704. Merge that one first:
new Array<number>()needs its defaulted-parameter fix, and the other tests below need its other-mm=ownfixes.Changes
entries()reads the element into a local before theyield. Own does not yet follow a tuple built from a borrow inside the yield itself. Elements that are numbers or strings work.class Array<T>is@sharedElements, asMapandSetare.concat,fillandslicecopy elements, and an object has one owner, so under own an object goes in asShared<T>.new Array<Node>()is now a compile error that points atShared<T>.entries,keys,values,[Symbol.iterator]) say@borrows("this"), asT[]'s do.filter2hands backT[]'s generator. As a generator itself, it returned that generator as its final value, so iterating it yielded nothing. This applies under every memory model.concatno longer spreadsotherinto a rest argument, which under own would move the arrays.array_class_spliceuses anArray<Item>, which own refuses by design, so it is marked// not own.Results
Each result holds in all four passes (release and debug, compile and JIT). The own tests that now pass:
array_entriesarray_everyarray_find2,array_find3catch_library_errorregexp_parse_examplesarray_concatandowning_copiesin the debug passStill failing under own
array_reduceRight,string_matchAllandstring_match_lastIndex. Fixing them needs compiler work, described in #704.🤖 Generated with Claude Code