Repository navigation
-mm=own: an object literal holding another module's fresh instance borrows it - #836
Merged
Merged
Conversation
…rrows it
JSON.stringify({ when: new Date(0) }) failed under -mm=own with "an object
literal that holds a value it owns is moved only into a local or returned
as it is". The literal's fields are classified (classifyRecordBoxes, in
computeFacts) before the imported Date..new call was marked as a fresh
result, so new Date(0) read as an unknown value. The imported `..new` and
--own-facts fresh results are now marked before the facts as well.
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.
Under
-mm=own,JSON.stringify({ when: new Date(0) })failed with "an object literal that holds a value it owns is moved only into a local or returned as it is; -mm=own cannot move it here yet". The same happens to any call given an object literal that holds a fresh instance of a class from another module. The same literal holding a class of the program's own module worked.Cause: the signature pass decides which object literals only borrow their fields (
classifyRecordBoxes, insidecomputeFacts) from whether each field's value is fresh. An imported class's..newcall (and a--own-factsfresh result) was marked fresh only in the loop aftercomputeFacts. So when the literals were classified,new Date(0)was an unknown value, and the literal was refused.new C()of the module's own class is ats.New, which is always fresh.Fix:
OwnershipSignaturePassmarks those calls fresh before the facts too (isImportedFreshResult, shared with the later loop).Test:
import_record_stamp.ts+export_record_stamp.ts(-shared; compile and jit; gc, rc, own). It passes a literal holding an imported class instance to a function, to a generic, two of them in one literal, and through a local. The previous compiler fails the own tests with that error.Testing: ctest 7042/7042 on Windows and 7023/7023 on Linux (WSL). The ownership verifier is clean. DefaultLib tests.ps1 passes under gc, rc, none and own.
🤖 Generated with Claude Code