Skip to content

delete of a local holding a number is an error - #587

Merged
ASDAlexander77 merged 1 commit into
mainfrom
delete-local-error
Oct 17, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
delete-local-error

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

const n = 5; delete n; compiled with no diagnostic. mlirGen(DeleteExpression) did fail ("the operand of a 'delete' operator must be optional"), but mlirGen(Expression) dropped its result, so the postponed error was never shown.

Fix:

  • the delete's failure now reaches the statement;
  • a bare identifier that is no class instance, array or new value gets TypeScript's message: The operand of a 'delete' operator must be a property reference (this covers let n = 5 and a string local too).

Repro (diagnostic-location/delete_local.ts):

class C {}

function main() {
    const c = new C();
    delete c;          // still fine: frees the instance
    const n = 5;
    delete n;          // 9:5: error: The operand of a 'delete' operator must be a property reference
}

A second dropped error, now fixed (rc/own): after delete c of 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.ts under rc and own_err_delete.ts failed. That internal cast now skips the strict-null check, so the store is made. Under -mm=own, own_err_delete reaches 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

`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>
@ASDAlexander77
ASDAlexander77 merged commit 89b37aa into main Oct 17, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the delete-local-error branch October 17, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant