Closed Bug 349851 Opened 18 years ago Closed 18 years ago

"yield \n ,3" compiles, but its decompilation does not

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8.1

People

(Reporter: jruderman, Assigned: brendan)

References

Details

(Keywords: testcase, verified1.8.1)

Attachments

(1 file)

> function(){ yield 
  ,3 }
function () { yield, 3; }

> function () { yield, 3; }
syntax error

I don't know where the bug lies -- it could be that the first is accepted, the way the first decompiles, or that the second is not accepted.
def foo():
  yield 12,42

returns the tuple (12, 42);

def foo():
  yield, 42

is a syntax error, because top-level yield statements require parenthesization in Python.  Enclosing parentheses results in a generator which yields None and on .next() throws StopIteration.

The latest ES4 dump on developer.m.o/es4/ gives the yield expression as "yield" AssignmentExpression without any [no line break here] between the two (as occurs with |return|, |continue|, and a few other constructs).  My tendency would be to insert [no line break here] in the production to conform with return.  If this were done, the former example would be a syntax error on the second line (",3"), and the latter would demonstrate the same behavior as the second Python example given here with parentheses inserted around the |yield|.  If this isn't done, then I think both examples should be equivalent (yield undefined, on .next() throw).
Assignee: general → brendan
OS: Mac OS X 10.4 → All
Priority: -- → P1
Hardware: Macintosh → All
Target Milestone: --- → mozilla1.8.1
Status: NEW → ASSIGNED
Flags: blocking1.8.1?
Flags: blocking1.8.1? → blocking1.8.1+
Blocks: geniter
Attached patch fixSplinter Review
Python doesn't have the comma operator at lower precedence than assignment, but JS does -- still, we need to reject yield, 3 and yield\n, 3 equally (also 1, yield\n, 3 -- hence the placement of the error check).

/be
Attachment #236366 - Flags: review?(mrbkap)
Attachment #236366 - Flags: review?(mrbkap) → review+
Attachment #236366 - Flags: approval1.8.1?
Fixed on trunk.

/be
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Checking in regress-349851.js;
/cvsroot/mozilla/js/tests/js1_7/geniter/regress-349851.js,v  <--  regress-349851.js
initial revision: 1.1
Flags: in-testsuite+
verified fixed 1.9 20060903 windows/mac*/linux
Status: RESOLVED → VERIFIED
Comment on attachment 236366 [details] [diff] [review]
fix

a=schrep for drivers.
Attachment #236366 - Flags: approval1.8.1? → approval1.8.1+
Fixed on the 1.8 branch.

/be
Keywords: fixed1.8.1
verified fixed 1.8 20060906 windows/mac*/linux
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: