Repository navigation
delete of a local holding a number is an error - #587
Merged
Merged
Conversation
`const n = 5; delete n;` compiled with no diagnostic. mlirGen(Expression)
dropped the delete's failure, so the error it had made ("must be
optional") was never shown. The failure now reaches the statement, and
an identifier that names no class instance, array or `new` value gets
TypeScript's message: the operand must be a property reference.
Deleting a class instance, an array or a `new` value stays.
Propagating the failure showed one more dropped error: under rc and own,
the null stored into a deleted variable's slot (so that its release at
scope exit does nothing) failed the strict-null cast, and the store was
never made. That cast now skips the strict-null check: it is not a null
the program stores. -mm=own's "'delete' is not supported" error is
reached again.
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.
const n = 5; delete n;compiled with no diagnostic.mlirGen(DeleteExpression)did fail ("the operand of a 'delete' operator must be optional"), butmlirGen(Expression)dropped its result, so the postponed error was never shown.Fix:
newvalue gets TypeScript's message:The operand of a 'delete' operator must be a property reference(this coverslet n = 5and a string local too).Repro (
diagnostic-location/delete_local.ts):A second dropped error, now fixed (rc/own): after
delete cof a variable with storage, the null stored into its slot (so the release at scope exit does nothing, see the comment there) went through a cast that failed the strict-null check, so the store was never emitted. Propagating the failure exposed this:00owned_delete.tsunder rc andown_err_delete.tsfailed. That internal cast now skips the strict-null check, so the store is made. Under-mm=own,own_err_deletereaches its intended "'delete' is not supported by -mm=own yet" error again.ctest -C Release -j 8 --timeout 300: 100% passed, 0 failed (4092 tests on this branch).🤖 Generated with Claude Code