diff --git a/changelog.d/9481-9249-strict-mode-store.md b/changelog.d/9481-9249-strict-mode-store.md new file mode 100644 index 0000000000..da6be8d5f5 --- /dev/null +++ b/changelog.d/9481-9249-strict-mode-store.md @@ -0,0 +1,16 @@ +**test(9249): opt the blocked-store case into strict mode (#9426 semantics)** + +`reflect_define_property_non_writable_prototype_index_blocks_array_store` +asserted a `TypeError` from a sloppy-mode script. #9426 made a rejected +array-element write throw **only in strict mode** — which matches node: + +| | output | +|---|---| +| Perry, with `"use strict"` | `TypeError 1 P` | +| Perry, as written (script) | `no error 1 P` | +| `node --experimental-strip-types`, same `.ts` | `no error 1 P` | + +Perry and node agree exactly, so the code is right and the expectation was +stale. The test's purpose — a non-writable inherited index BLOCKS the store — +is still worth keeping, so it opts into strict mode rather than weakening the +assertion to the sloppy no-op. diff --git a/crates/perry/tests/issue_9249_array_prototype_define_property.rs b/crates/perry/tests/issue_9249_array_prototype_define_property.rs index 7abc78182f..9aa254290d 100644 --- a/crates/perry/tests/issue_9249_array_prototype_define_property.rs +++ b/crates/perry/tests/issue_9249_array_prototype_define_property.rs @@ -111,7 +111,15 @@ console.log(hits, values.length, values[5]); #[test] fn reflect_define_property_non_writable_prototype_index_blocks_array_store() { compile_and_run( - r#" + r#""use strict"; +// #9426 made a rejected array-element write throw ONLY in strict mode, which +// is what node does. This file is a bare .ts — the oracle +// (`node --experimental-strip-types`) runs it as a SCRIPT, i.e. sloppy, where +// the rejected store silently no-ops in node too: +// $ node --experimental-strip-types +// no error 1 P +// The point of this test is that a non-writable inherited index BLOCKS the +// store, so it opts into strict mode rather than asserting the sloppy no-op. Reflect.defineProperty(Array.prototype, 11, { value: "P", writable: false,