Bug 26904 - Suppress 'undefined' in JSC program display
Summary: Suppress 'undefined' in JSC program display
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Trivial
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-01 14:21 PDT by Brent Fulgham
Modified: 2009-07-01 14:28 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2009-07-01 14:21:17 PDT
If you play with the JSC program, you can perform various calculations and see results:
> 1 + 2
3
> "hello"
hello

The problem is if you attempt to create a variable binding, which does not return a value.  In this case, the JSC program reports 'undefined', which is a surprising result and might confuse a user into thinking an error has occurred.  For example:

> var add2 = function(arg) { return arg + 2; }
undefined
> add2(15)
17

It seems like it would be better if the transcript looked like the following:
> 1 + 2
3
> var add3 = function(arg) { return arg + 3; }
> add3(15)
18
Comment 1 Oliver Hunt 2009-07-01 14:28:52 PDT
The result printed is the result of the expression.  While it may seem odd that "var x = 5" displays undefined that is specified behaviour.  Not doing so would create even more confusion as eval("var x=5") will correctly display undefined.

There's also a reasonable concern that changing this behaviour would break the mozilla js test suite you hit with run-javascriptcore-tests