Bug 143066 - Poor runtime error message dealing with undefined in strict mode compared to non-strict mode
Summary: Poor runtime error message dealing with undefined in strict mode compared to ...
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-25 16:46 PDT by Joseph Pecoraro
Modified: 2017-01-18 23:39 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-03-25 16:46:17 PDT
* SUMMARY
Very poor runtime error message dealing with undefined in strict mode compared to non-strict mode.

* TEST
<script>
"use strict";
function Foo() {
    this._key = undefined;
    this._key.name = "test";
}
new Foo;
</script>

* NON-STRICT (expected)
[Error] TypeError: undefined is not an object (evaluating 'this._key.name = "test"')

* STRICT (actual)
[Error] TypeError: Attempted to assign to readonly property.

* NOTES
- Because Classes imply strict mode and we've started making heavy use of classes, this will greatly impact us when working on WebInspector.
Comment 1 Timothy Hatcher 2015-03-25 17:30:07 PDT
This stumped me for a while today.
Comment 2 Saam Barati 2015-03-27 17:32:31 PDT
I'll take this