Javascript error required for Generators that return

RESOLVED FIXED in 1.7R1

Status

Rhino
Core
--
enhancement
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: Roshan James, Assigned: Roshan James)

Tracking

other
1.7R1
x86
Linux
Dependency tree / graph

Details

Attachments

(1 attachment)

(Assignee)

Description

11 years ago
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

Updated

11 years ago
Assignee: nobody → roshanj

Updated

11 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true

Updated

11 years ago
Depends on: 379377, 379381
Target Milestone: --- → 1.7R1
(Assignee)

Comment 1

11 years ago
Created attachment 267320 [details] [diff] [review]
Patch: adds required errors

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.

Comment 2

11 years ago
Committed patch on date: 2007/06/06 14:32:39 and enabled test.

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