The default bug view has changed. See this FAQ.

Warn about 'yield' without operand

RESOLVED FIXED in mozilla25

Status

()

Core
JavaScript Engine
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: jorendorff, Assigned: jorendorff)

Tracking

({dev-doc-complete, site-compat})

unspecified
mozilla25
dev-doc-complete, site-compat
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
In a generator, we parse

    yield
        f();

as two statements, meaning

    yield undefined;
    f();

But in ES6, this will parse as a single statement:

    yield f();

Users should be warned.

(We may not break their code, at least not immediately, since ES6 generators are distinguished from JS1.7+ generators by the "*". But people will naturally want to port up to ES6, and we don't want them to hit silent breakage. So a warning is in order.)
(Assignee)

Comment 1

4 years ago
Steal this bug if you have time. I'm going to try and get this into FF24 though.
Assignee: general → jorendorff
(Assignee)

Comment 2

4 years ago
Created attachment 765663 [details] [diff] [review]
v1
Attachment #765663 - Flags: review?(jwalden+bmo)
Comment on attachment 765663 [details] [diff] [review]
v1

Review of attachment 765663 [details] [diff] [review]:
-----------------------------------------------------------------

Awesome.  Land it!

::: js/src/jit-test/lib/asserts.js
@@ +72,5 @@
> +                print("assertWarning: " + msg);
> +            throw exc;
> +        } finally {
> +            if (!hadWerror)
> +                options("werror");

Guh, options() is not a good interface.
Attachment #765663 - Flags: review?(jwalden+bmo) → review+
(Assignee)

Comment 4

4 years ago
No kidding. Filed bug 885766.
https://hg.mozilla.org/mozilla-central/rev/818298a5a183
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla25

Updated

4 years ago
Blocks: 889104
Blocks: 889527
Depends on: 891806
(Got here from Bug 891806)

Why do we need yield undefined; and not just yield; ?
I can understand 
yield 
  f(); needing some change, but will yield; mean something totally 
different than what it is currently?
(Assignee)

Comment 7

4 years ago
Unless the proposal changes, `yield;` will be a SyntaxError. We plan to implement the standard (soon) and remove the SpiderMonkey-only extensions (eventually).

smaug, I encourage you to take this to es-discuss! If "yield undefined" looks ugly in Moz-only code, then it'll look just as ugly in Web code, which will follow the new standard syntax.

Since you have existing real-world code, you are in a position to make a uniquely convincing argument. You've seen the future, you've lived there, you're proposing a simple feature that makes the future prettier.

Individuals can make a difference on TC39. Please give it a shot if you really care about this syntax.
Added: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/25/Site_Compatibility
Keywords: dev-doc-complete, site-compat
You need to log in before you can comment on or make changes to this bug.