Bug 160984

Summary: Make custom Error properties (line, column, sourceURL) configurable and writable
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: JavaScriptCoreAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, joepeck, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Joseph Pecoraro
Reported 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.
Attachments
[PATCH] Proposed Fix (6.07 KB, patch)
2016-08-18 17:06 PDT, Joseph Pecoraro
no flags
Joseph Pecoraro
Comment 1 2016-08-18 17:01:24 PDT
Joseph Pecoraro
Comment 2 2016-08-18 17:06:58 PDT
Created attachment 286418 [details] [PATCH] Proposed Fix
WebKit Commit Bot
Comment 3 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>
WebKit Commit Bot
Comment 4 2016-08-19 15:51:11 PDT
All reviewed patches have been landed. Closing bug.
Joseph Pecoraro
Comment 5 2016-08-19 19:01:03 PDT
*** Bug 146047 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.