Closed Bug 383164 Opened 17 years ago Closed 17 years ago

Javascript error required for Generators that return

Categories

(Rhino Graveyard :: Core, enhancement)

x86
Linux
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: roshanj, Assigned: roshanj)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Build Identifier: 1.6R6

A generator that returns a values must be flagged by an error;.

function (x) {
 yield x;
 return x+1;
}

Must be flagged by an error. 

Reproducible: Always
Assignee: nobody → roshanj
Status: UNCONFIRMED → NEW
Ever confirmed: true
Depends on: 379377, 379381
Target Milestone: --- → 1.7R1
The patch adds the required error messages. These errors are flagged all the time (not just on strict mode). 

Strict mode warnings have been extended to do reachability analysis that accommodates mismatched uses of yield and value-returns.

js> function foo(x) { var a = 10; x =x + 1; if(x < 1) { return x; } yield x; yield x + 1; }
js: "<stdin>", line 2: generator function foo returns a value
js: function foo(x) { var a = 10; x =x + 1; if(x < 1) { return x; } yield x; yield x + 1; }
js: .......................................................................^
js: "<stdin>", line 2: Compilation produced 1 syntax errors.
Committed patch on date: 2007/06/06 14:32:39 and enabled test.

Marking fixed. 
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: