Repository navigation
x.name and x[k] = v of a value of type any; a write of an optional interface field with no place throws - #942
Merged
Merged
Conversation
…(ANY_KEYS_OP_SET); a write of an optional interface field an object has no place for throws - `x.name` of `x: any` is `x["name"]`, read at run time; the member probe (evaluatePropertyValue) still finds none on `any`, as `i in a` asks it of `length` - `x[k] = v`, `x.name = v`, `+=` and `++` write through the adapter: a plain `=` makes no read (a getter does not run); a key the type has not got, a method, an accessor with no setter, a tuple's key (the `any` holds a copy) and a value not of a number, string or boolean key's kind are TypeErrors; an array is written in range or one past its end - `s[i]` of a string in an `any` is a string, as in JavaScript (it was a char) - `i.o = v` of an interface whose object was made without the optional field `o` stored through a null address: it throws Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r a key whose value copies Under own a key's value is read as a copy in a box of its own and written as a copy of the value, so a key holding a number, a boolean, a string or an `any` is read and written through `any`; one holding an object is a TypeError on read and write (it would be a second owner), as is a write through an interface and an array grown through `any` (own can't prove the unboxed value alive across them). `in` asks of every key. The adapters unbox where they use the value under own. Test 00any_keys_models.ts runs under every model; the own compile errors for x[k] and k in x are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wn failed own's checks in the default library (Error classes, an interface holding a method) and in 00any_to_interface.ts, where they reached programs that never read a key; own keeps its clear error This reverts commit b57b5b0. 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.
x.nameandx[k] = v(+=,++) of a value of typeany, read and written at run time through the keys adapter of #940 (new opANY_KEYS_OP_SET). Follow-up to the 11-19 ruling.What works (gc, rc, none)
x.nameofx: anyisx["name"]. The member probe (evaluatePropertyValue) still finds nothing onany, becausei in aasks it aboutlength.x[k] = v,x.name = v,+=and++write through the adapter. A plain=does no read first, so a getter doesn't run.anyholds a copy);"hi"silently became0.s[i]of a string in ananyis now a string (it was a char).any-specific: writing an optional interface field to an object made without it (const i: I = { n: 1 }; i.o = "a") stored through a null address and crashed. It now throws.-mm=own: still the clear compile error. The own variant (copyable keys only) was tried and reverted inside this PR: its adapters failed own's borrow checks in the default library (the Error classes) and in00any_to_interface.ts, so they broke programs that never read a key.Tests:
00any_keys_write.ts.any_key_assign,any_key_compoundandany_key_incrementerror tests, which now compile.Checked locally
arrayConcatMap.ts, now crashes instead of failing with an error. The crash is older than this PR: boxing an element of[].concat([1])intoanycrashes the older compiler too. The test reaches it now thatb.acompiles.🤖 Generated with Claude Code