This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 262144 - [PHP7] Syntax error with yield
Summary: [PHP7] Syntax error with yield
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-18 18:20 UTC by m6w6
Modified: 2016-11-12 03:15 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
yield syntax error (47.16 KB, image/png)
2016-05-18 18:20 UTC, m6w6
Details
screenshot (37.76 KB, image/png)
2016-11-09 11:08 UTC, junichi11
Details

Note You need to log in before you can comment on or make changes to this bug.
Description m6w6 2016-05-18 18:20:13 UTC
Created attachment 159806 [details]
yield syntax error

Not sure, what the problem is, maybe it expects parens?

See screenshot and also bug #262141
https://netbeans.org/bugzilla/show_bug.cgi?id=262141
Comment 1 Tomas Mysik 2016-05-19 10:19:51 UTC
The problem is that out parser does not expect "yield ..." after "=" (the same applies for "yield from ..."). Again, current limitations of our PHP support internals. We are trying to fix it but it is not easy, sorry.

Thanks.
Comment 2 junichi11 2016-11-09 11:04:22 UTC
I'll do it.

Thanks.
Comment 3 junichi11 2016-11-09 11:08:40 UTC
Created attachment 162844 [details]
screenshot

Do you have other cases? If you have them, please let us know.

Thanks!

yield;
(yield);
yield yield;
(yield yield);
yield yield 2;
(yield yield 2);
yield $i;
(yield $i);
yield $key => $value;
(yield $key => $value);

$a = yield;
$a = (yield);
$a = yield yield;
$a = (yield yield);
$a = yield yield 2;
$a = (yield yield 2);
$a = yield $i;
$a = (yield $i);
$a = yield $key => $value;
$a = (yield $key => $value);
$a = $b = yield $key => $value;
$a = $b = (yield $key => $value);
$a = ($b = (yield $key => $value));
($a = yield);
$a = yield $test->foo->{"bar"}->baz();

yield yield from from();

yield from $from;
(yield from $from);
yield from from();
(yield from from());
yield from new ArrayIterator([2, 3, 4]);
(yield from new ArrayIterator([2, 3, 4]));

$c = yield from $from;
$c = (yield from $from);
$c = yield from from();
$c = (yield from from());
$c = yield from new ArrayIterator([2, 3, 4]);
$c = (yield from new ArrayIterator([2, 3, 4]));
$c = $d = yield from from();
$c = $d = (yield from from());
$c = ($d = (yield from from()));
($c = ($d = (yield from from())));
return yield from from();
return (yield from from());
Comment 4 junichi11 2016-11-11 01:57:06 UTC
Fixed.

http://hg.netbeans.org/web-main/rev/ad833dc403d5

I hope that there isn't anything missing/wrong fix...

Added expr_with_yields to restrict yield expressions to only equal assignments in the CUP file. If we don't want to restrict to it, add yield_expr and yield_from_expr to expr_without_variable_and_class_instance, then replace expr_with_yields to expr, remove expr_with_yields.

Thanks!
Comment 5 Tomas Mysik 2016-11-11 07:08:39 UTC
Thanks a lot, Junichi! Great job!
Comment 6 junichi11 2016-11-11 10:44:45 UTC
You are welcome :)
Comment 7 Quality Engineering 2016-11-12 03:15:52 UTC
Integrated into 'main-silver', will be available in build *201611120001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ad833dc403d5
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #262144 - [PHP7] Syntax error with yield

Added expr_with_yields to restrict yield expressions to only equal assignments in the CUP.