Bug 160984 - Make custom Error properties (line, column, sourceURL) configurable and writable
Summary: Make custom Error properties (line, column, sourceURL) configurable and writable
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
: 146047 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-18 17:01 PDT by Joseph Pecoraro
Modified: 2016-08-19 19:01 PDT (History)
7 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (6.07 KB, patch)
2016-08-18 17:06 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-08-18 17:01:07 PDT
Summary:
Custom Error properties (line, column, sourceURL) should be writable and configurable

Steps to Reproduce:
>>> "use strict"; (new SyntaxError).line = 1;
Exception: TypeError: Attempted to assign to readonly property.

--

Some JavaScript libraries (Objective-J) expect to be able to assign to the "line" and "column" properties of a SyntaxError instance they create. This currently doesn't work in Safari where these properties are readonly.

>    function raise(pos, message) {
>      if (typeof pos == "number") pos = getLineInfo(input, pos);
>      var syntaxError = new SyntaxError(message);
>      syntaxError.line = pos.line;
>      syntaxError.column = pos.column;
>      syntaxError.lineStart = pos.lineStart;
>      syntaxError.lineEnd = pos.lineEnd;
>      syntaxError.fileName = sourceFile;
>
>      throw syntaxError;
>    }


In strict mode, this throws an exception, which was unexpected. We should be more lenient.

Notes:
- These properties are non-standard. Firefox adds (lineNumber, columnNumber, fileName). I didn't see any in Chrome.
- Non-standard Error properties added by JavaScriptCore are currently readonly and enumerable.
- All other engine non-standard error properties are configurable, writable, and not enumerable.
- Lets start by making them configurable/writable.
Comment 1 Joseph Pecoraro 2016-08-18 17:01:24 PDT
<rdar://problem/27905979>
Comment 2 Joseph Pecoraro 2016-08-18 17:06:58 PDT
Created attachment 286418 [details]
[PATCH] Proposed Fix
Comment 3 WebKit Commit Bot 2016-08-19 15:51:05 PDT
Comment on attachment 286418 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 286418

Committed r204663: <http://trac.webkit.org/changeset/204663>
Comment 4 WebKit Commit Bot 2016-08-19 15:51:11 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Joseph Pecoraro 2016-08-19 19:01:03 PDT
*** Bug 146047 has been marked as a duplicate of this bug. ***