Commit Graph

63 Commits

Author SHA1 Message Date
Jens Johansen ac9b4aab8d [parser] More specific error messages when recovering new/const/Map/Set/List with said literals
Follow-up to https://dart-review.googlesource.com/c/sdk/+/190022

Change-Id: Id42336216267dcbf481ae6e111177e6296ea6779
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-03-25 13:27:03 +00:00
Jens Johansen fd89f1176b [parser] Test for (already fixed) issue 45327
The crash reported in #45327 was already fixed, but for good measure
we'll add the provided examples as tests.

Change-Id: I74f3b78b8644712322d0fb582bbbbde291a8994e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191366
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-03-16 14:45:00 +00:00
Jens Johansen 31acdc9d92 [parser] Recovery of of new/const/Map/Set/List with said literals
E.g. recover `Map<int, int>{}` by ignoring the map (i.e. it's
just a literal map), recover `new {}` as just `{}` etc.

Fixes #45251.

Change-Id: I44e67ca6d3b9b068014b8e28822a61063c794d57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190022
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-03-12 10:41:06 +00:00
Jens Johansen 1392263ecc [parser] Non-crashing recovery of in-progress generification of typedef
Fixes #43090

Change-Id: I1377ebf08a8c561e4f15abbf458c5bb0d8c61494
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182040
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-04 08:01:07 +00:00
Jens Johansen 16a66c8902 [parser] Don't crash, try to recover from written out logical operators and and or
Fixes #44785

Change-Id: I4c7198ea1c223900a58039c032ee303d7da2c14f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181580
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-01 09:30:48 +00:00
Johnni Winther 63373b9e9c [cfe,analyzer] Pass message arguments directly to AnalysisError
This allows for supporting customized message for scanner/parser
errors.

Change-Id: Ib9470c3d8231de69611bc672570ae8902e9c0e6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-01-11 16:45:26 +00:00
Jens Johansen f7052cfbbc [parser] Better handling of eof when parsing 'Stream<List<>>'
This CL avoids the infinite loop created by allowing the parser
to parse it as a complex type (despite no actual name after it) and
adds a few asserts in an attempt to catch rewriting on eof (setting a
token after eof).

Fixes #42229
Fixes #44477

Change-Id: Ie2da0957894067a3d4748cb6384bc9d6cf32c215
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150521
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-01-11 09:55:06 +00:00
Jens Johansen e6ffc0b285 [parser] Issue different warnings for missing identifier based on whether the token is used or not.
E.g. "var = 42;" now has a different error message than "var default = 42;".

Fixes #22553

Change-Id: I58affe988569d8e79190b63f7267b471a1b0ebc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162182
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-14 08:55:18 +00:00
Jens Johansen b0acaea1e5 [parser] Recover written out binary operators
* Add mechanisms to try out a recovery and only perform it if is
  successful.
* Recover written out binary operators, e.g. "a xor b", "a or b" etc.
  This fixes #26810 and is also how these operators are written in e.g.
  Kotlin. This might be somewhat controversial though.
* Adds a mechanism to _replace_ a token by another token.
  This might be controversial.
  It is done because just inserting the operator causes the same rewrite
  to be attempted on the same token stream several times (at least with
  the way the token stream is parsed via the CFE) in turn causing it to
  be recovered *sometimes*. This is now avoided by actually replacing
  the token.

Change-Id: Icfa806045575d2aa2e5f35126708651b275bcf84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162003
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-10 06:23:33 +00:00
Jens Johansen a06e53b557 [parser] Set forIn = true when recovering 'in' written as ':'
Before this change the CFE crashed with an assert error.

Change-Id: Ide486388fbba8c6cda4bb75e5339ae3c10623351
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161949
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-09-09 06:41:14 +00:00
Jens Johansen b4673b58b9 [parser] Better recovery of typedefs with missing 'Function' keyword
This CL improves recovery in situations like this:

typedef c = foo(int x);
 => recovers like typedef c = foo Function(int x);

typedef d = (int x);
 => recovers like typedef d = Function(int x);

typedef e = foo<F>(int x);
 => recovers like typedef e = foo<F> Function(int x);

typedef f = <F>(int x);
 => recovers like Function<F>(int x);

typedef g = foo<F, G, H, I, J>(int x);
 => recovers like typedef g = foo<F, G, H, I, J> Function(int x);

typedef h = <F, G, H, I, J>(int x);
 => recovers like typedef h = Function<F, G, H, I, J>(int x);

typedef i = <F, G, H, I, J>;
 => recovers like typedef i = Function<F, G, H, I, J>();

And appropriate error messages are given:
"Expected 'Function' before this." and (when inserting parenthesis)
"A typedef needs an explicit list of parameters.".

Fixes #26073.

Change-Id: I368f36f2993033d62b36315198bc993eed74bc92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161485
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-08 11:43:14 +00:00
Jens Johansen 3a1f732c0f [parser] Make begin/end events always come in pairs
This CL:
* Changes the events so beginX and endX events always comes in pairs
  (though technically not right as some specific events can be beginX
  endY --- but in those cases it is at least documented and used in code
  that actually tests it).
  -> This entails adding some events and converting something from
    "beginX" to "handleX" instead.
* Adds a utility that can generate an AST of sorts directly from the
  parser via a listener using the begin/end matching (and knowing of the
  specific ones that doesn't match directly).
* Adds a test that checks that - at least for all tested (50,000+) files
  - the AST actually generate "correctly", i.e. matches up begin/ends
  and ends up with a single top entry "CompilationUnit".
* Adds a different visualization to the parser listener events by
  displaying the "AST directly from the parser" in a UI that can be
  navigated. The visualization may not be the best, but it's certainly
  a stepping stone.

Change-Id: I9b27f7bbf3be442adc92f357c7b3c46da6f84cf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159664
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-01 09:30:43 +00:00
Jens Johansen 0967d19156 [parser] Fix assert error in scanner
If an identifier starts with a non-ascii-character and has a comment
an assert was triggered about the comment not being attached to the
token. This CL attaches the comment to the token (which it should be)
and thus avoiding the assert trigger.

Change-Id: Id261970b88ca721d4b3a996abfb8ff43f0ec8341
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161102
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-08-31 14:19:48 +00:00
Jens Johansen 8bca93872a [parser] Better error message for annotations on type arguments
This CL changes the message given in the situation identified in
https://github.com/dart-lang/sdk/issues/22314

Fixes https://github.com/dart-lang/sdk/issues/22314

Change-Id: Ibd47dd419d52673ae0d9e32039e0a635c1e09543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158388
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-08-17 07:43:52 +00:00
Jens Johansen 7e42cbf582 [parser] Change recovery of multiple extends with comma
E.g. class Foo extends Bar, Baz {} would before have parsed weirdly,
but it will parse as you'd (probably) expect with an error saying
you cannot do that. For now at least both CFE and Analyzer will
pretend like you just specified the first one but I suppose Analyzer
could for instance use the extra information to propose converting
other ones to implements clauses or similar.

Fixes https://github.com/dart-lang/sdk/issues/22313

Change-Id: I180cdd8ab07143dd74fd21c9976ec2a46c428d8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158261
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-08-13 08:49:53 +00:00
Jens Johansen b6423f1f81 [CFE] Make parser_test_listener up-to-date
This also changes lots of expect files.
I don't know how it got out-of-date --- I actually thought that was
tested. It seems it's not...

Change-Id: I6dd524908b8735a5889ed6fdb59be5383e4e8237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158301
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-08-12 14:28:54 +00:00
Johnni Winther a021b99fc3 [cfe] Fix scope setup for generic function types
Closes #36870
Closes #41951
Closes #42364

Change-Id: Id323bfdc26c688bfeb756ef8c1e0530283b44e34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156028
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-07-29 09:04:24 +00:00
Johnni Winther 92f4eb58c8 [cfe] Support abstract fields
Only positive implementation, no error states are checked yet.

Change-Id: Iad79da1dd7e8be9229ee9d47c5301d39ebc3debc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154003
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-16 10:13:23 +00:00
Paul Berry 8cb7dfa70f Modify parser to handle abstract fields.
There is no functional change to the analyzer or CFE yet; we simply
report the error in the parser listeners now rather than the parser
itself.  In follow up CLs when we add full support for the feature, we
will want to keep the error reporting logic, but only report the
errors in pre-NNBD code.

Change-Id: Ifd14dd97d7d1d57586a8e14a25103356d54f0ea1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154364
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-07-15 22:48:01 +00:00
Johnni Winther 9ab7a5edef [cfe] Use variable name in error message for missing initializer
Closes #42610

Change-Id: I70a5ac9302bd6545cd5e73f2dab61a29bc6a3000
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153462
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-07-08 12:45:15 +00:00
Jens Johansen 50836c171e [parser] Fix parsing of empty index in cascade
Fixes #42267

Change-Id: Ia09fd9e564bc0b04cdd99d3aac5093a12ab10d96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150926
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-06-12 06:36:58 +00:00
Jens Johansen c800b8d19c [parser] Parser tests reproducing bad recovery of 'Stream<List<>>'
Reproduction of issue #42229.

Change-Id: I0c70f04663e37d4ed35a70501024cd3cead8c849
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150520
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-06-10 07:10:50 +00:00
Jens Johansen cbbbc09b3e [parser] Better recovery of typedefs with bad name
Note that this leaves differences in errors issued between
"typedef void void();" and "typedef void = void Function();" though.

Fixes #42158

Change-Id: I0785f99234c87bdeadbb2865e089b1389851333e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149599
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-06-04 14:21:11 +00:00
Jens Johansen 1b5197e55f [parser] Update parser tests for using keywords as methods/fields/typedefs
The previous tests only tested out reserved keywords (here updated to all
keywords) and forgot about typedefs altogether (added here).

Change-Id: Ibb98ef5e3342077343484640c9ebf6bc239164dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149597
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-06-03 10:12:29 +00:00
Paul Berry 3ca37fb66e Re-apply some recent parser fixes.
My recent revert (275b922ee8) mistakenly
reverted too much (I incorrectly attributed the angular failure to
1f9b5c1996 when it was actually due to
96df1f9e6c).  Reapply the commits that
are ok.

This re-applies commit 1f9b5c1996.
This re-applies commit c40b24da48.

Change-Id: I4d64b1511b92d87197a5e939903a31e01f0b2e70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147920
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-13 16:00:01 +00:00
Paul Berry 275b922ee8 Revert recent parser fixes
Commit 1f9b5c1996 causes tests to fail
in angular when rolled into internal sources; the other two commits
need to be reverted as well to avoid merge conflicts.

This reverts commit 1f9b5c1996.
This reverts commit c40b24da48.
This reverts commit 96df1f9e6c.

Change-Id: Ic4e55181ef60e825ce4409a9a9528ecbf19c39c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147822
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-12 22:02:09 +00:00
Jens Johansen 96df1f9e6c [parser] Add ErrorToken for ignored (unmatched) end parenthesis, brackets etc
Change-Id: Idb57295700988d71321743af9782134b02562311
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146240
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-11 14:46:47 +00:00
Jens Johansen c40b24da48 [parser] Show errors from 'handleErrorToken' in parser suite tests
Change-Id: I3528136b6c220f0fe72d9d7b2aa591737c4c7096
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146225
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-07 11:23:48 +00:00
Jens Johansen 1f9b5c1996 [parser] Recovery of unbalanced parenthesis, brackets etc.
Bug: https://github.com/dart-lang/sdk/issues/41000

Change-Id: I8d1d8ff5d3f832f9b6b5e5880b59a485a7ff9b96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146224
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-07 10:04:08 +00:00
Jens Johansen 5b76fc2172 [parser] Better recovery of methods/fields called 'const', 'final', 'var' or 'void'
Change-Id: I370089a6de8c585a60785fe069de5da869ae23f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145820
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-06 11:56:24 +00:00
Jens Johansen 497bdc5226 [parser] Some recovery from using reserved words as method/field names
Change-Id: I9795ecc28f06d1f9410066ded73405019052947d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145586
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-05-05 07:56:33 +00:00
Jens Johansen a840da4617 [parser] Tests of using build in identifier and reserved keywords as method/field names
Bug: https://github.com/dart-lang/sdk/issues/40419
Change-Id: Ide0fabc4466714a7f9bb9a4474c80a3dfafde56f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145584
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-05-01 07:40:46 +00:00
Jens Johansen 676c2df9a2 [CFE] Fix parser expect output when there's errorTokens all over the place
Change-Id: I5509f866bb33e91f49d873678761e00ce8601654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144284
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-04-21 13:03:43 +00:00
Jens Johansen 97e0983094 [parser] Fix NP in scanner caused by never setting eof
This e.g. happends on input that's UTF-16 LE.

Also see https://github.com/flutter/flutter/issues/54840.

Note that this doesn't really fix much, because the scanner still
tries to read the input as utf8 (which it potentially isn't, and isn't
in the test cases added) and it thus basically outputs garbage.

Change-Id: I7198928dc6f0dd16728c1c04ccd4286faae8dd20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143586
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-04-20 13:21:46 +00:00
Jens Johansen 9f06c32b45 [CFE] Fix crash when implementing or mixing in a functionType
Bug: 41265
Change-Id: Idf4fbc44c210008c3c94639c138adbd3afec2cef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143522
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-04-16 06:35:50 +00:00
Jens Johansen 4ab3bda5db [parser] Change recovery for constructor; report errors in bad constructors
Change-Id: I3d656afce4a3ec14c7c099893a434abba3945ebf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-27 11:57:56 +00:00
Jens Johansen 81768cbd7f [CFE] Update parser_test_parser and expect files
Change-Id: I8620aa9b762d7f49262635e482d1e16d70d46e2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138926
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-12 11:25:02 +00:00
Konstantin Shcheglov 0649115b06 Rename VoidWithTypeParameters to VoidWithTypeArguments.
Change-Id: I5df6a49f0b27b6edfe2ce0f677d5f898900d8384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138341
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-03-05 17:31:34 +00:00
Jens Johansen f828f00b59 [parser] Error recovery of type parameters on void
Fixes #39958.

Change-Id: I851bef762776f4b68f0fcb645d634019b8b32e81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137925
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-04 14:02:35 +00:00
Sam Rawlins 19dc177a82 Missed one expectation change in parser recovery test
Change-Id: I3592dfa6c2ed0f704a34975d35d02a4073830834
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-03-03 18:39:44 +00:00
Sam Rawlins e7e45599cb Improve error recovery of misplaced await or yield
Bug: #32967
Change-Id: I9f8e2ae434ea79470949e7931bcb80c542c54f33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138042
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-03-03 14:58:21 +00:00
Sam Rawlins e687b62ffe Improve recovery on yield not-in generator; Improves #32967
Fix is inspired by very similar recover for `await` in synchronous
function, like `looksLikeAwaitExpression` and `endInvalidAwaitExpression`.

Change-Id: I50bf0c1e73c31551b94de29d78fd3d449c30fd20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136920
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-03-02 17:29:22 +00:00
Jens Johansen 3969356f1a [parser] Parse bangs before type parameters correctly
Change-Id: Ie05e57d12cdbdeac037785ef6b94497c77d264ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137789
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-03-02 11:21:40 +00:00
Jens Johansen 1b534d04a8 [CFE] Change parser test output slightly
Special handling of beginBinaryExpression/endBinaryExpression as they
don't always comes in pairs.

Change-Id: I74323dd45615fbb340acc1c5144b0ba94ea19f5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137783
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-02 08:22:03 +00:00
Jens Johansen 3660b9ecc7 [parser] New syntax for null aware index (2nd try)
This reverts commit bc4893a3b3.

The previous attempt failed because when we check if something is a
conditional expression we used a rewriter that didn't actually rewrite.
This further down the line (still checking if we can parse the expression)
results in errors occurring (that wouldn't have occurred if the rewrite
had happened) and the conclusion was thus that it wasn't a conditional
expression and we parsed it as a null-aware index operator (which gave
errors because it wasn't).

This 2nd try solves it by having a rewriter that actually rewrites,
but then allows to undo the rewrites after we're done parsing.

Change-Id: Ide3c0d6a870d4dc18b6d9475b0227d93c733dc7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136624
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-02-26 13:31:52 +00:00
Jens Johansen bc4893a3b3 Revert "[parser] New syntax for null aware index"
This reverts commit cf4e044e07.

Reason for revert: Breaks internal customer.

Original change's description:
> [parser] New syntax for null aware index
> 
> Change-Id: Iea6b29eb897eb01863a92b223e270d225c3ca1ba
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135903
> Commit-Queue: Jens Johansen <jensj@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

TBR=brianwilkerson@google.com,jensj@google.com,johnniwinther@google.com

Change-Id: Ic0ff607c944e489f29bda7da37afd63c62d368eb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136600
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-02-20 14:11:08 +00:00
Jens Johansen cf4e044e07 [parser] New syntax for null aware index
Change-Id: Iea6b29eb897eb01863a92b223e270d225c3ca1ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135903
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-02-20 12:33:28 +00:00
Karl Klose bd06f1bf51 [cfe/infra] Unit test suites: print re-run command when a test fails
Closes #39423

Change-Id: Ifa3fbe4d670f4f95beceb2aae8769a553a9fbe7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125604
Commit-Queue: Karl Klose <karlklose@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-22 10:45:54 +00:00
Jens Johansen fe3afde2eb [CFE] Parser: Don't report (recovered) operator as endClassConstructor
Before this CL any method with initializers would be ended with a call
to listener.endClassConstructor.
If we know it's an operator, though, we shouldn't: The listener has
most likely created a specific operator name and should't call it a
constructor.

Bug: 39230
Change-Id: I6ee79ba1907cb3932c461e0b00937af23b5b5edb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124121
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-11-06 09:42:37 +00:00
Jens Johansen c75e5e4cf4 [CFE] Fix assert in parser
Change-Id: Iee9059c1f7c87191f4d4551c8c9e50766d0a520f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123731
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-11-04 08:05:52 +00:00