Commit Graph

41 Commits

Author SHA1 Message Date
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 c36d4d65af [parser] Give errors when 'external' comes in wrong order
Fixes https://github.com/dart-lang/sdk/issues/43851
Fixes https://github.com/dart-lang/sdk/issues/43858
Fixes https://github.com/dart-lang/sdk/issues/43859

Change-Id: I33c9cde01a0843efba3ca0d0a679f4e31b06237c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168650
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-23 09:19:01 +00:00
Jens Johansen 553230ffb4 [parser] Give errors when 'abstract' comes in wrong order
Fixes https://github.com/dart-lang/sdk/issues/43855
Fixes https://github.com/dart-lang/sdk/issues/43856
Fixes https://github.com/dart-lang/sdk/issues/43857

Change-Id: I83ee716288741d2d84a1993e9743ad4b82af22ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168646
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-23 08:05:31 +00:00
Jens Johansen 5a6129406f [parser] Consistently disallow 'late' without 'var', 'final' or type
Fixes https://github.com/dart-lang/sdk/issues/43811
Fixes https://github.com/dart-lang/sdk/issues/43812
Fixes https://github.com/dart-lang/sdk/issues/43813

Change-Id: I39de527883d33459694ec0f91b769676eb52d54b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168641
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-23 06:28:51 +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 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 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
Jens Johansen 4c0cab024e [parser] No longer support ?.[ syntax
Update CFE tests (and a few analyzer tests) to match the new world
of the syntax being unsupported.

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

Change-Id: I71bc973f36dfb978ddb825edb68530d8e260a58a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157980
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-11 08:09:59 +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
Jens Johansen 01ac35b844 [parser] Allow '..' as something following a nullable type
Fixes https://github.com/dart-lang/sdk/issues/42621

Change-Id: I56fd9475ffb3821592a6917949e858c6e48bdf20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153773
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-07-09 15:03:17 +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 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
Johnni Winther 712efa2a49 [cfe] Handle problems and recovery in non-null check
Closes #41597

Change-Id: I781d70d7cd720ab09d68a22ead1639bf37953955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144941
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-04-28 08:06:48 +00:00
Johnni Winther 594f77715b [cfe] Handle potentially constant type expression in is expression
Closes #41385

Change-Id: Ia2fa829621931d52c5e41ac0414d12b9caa1256d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142860
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-04-16 09:07:21 +00:00
Johnni Winther fae35fca47 [cfe] Handle potentially constant type expressions in CFE
Closes #41305

Change-Id: Ibb839c5b6619ae2f7e90cc956c7de20d8c76ae3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142120
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-04-02 13:23:04 +00:00
Jens Johansen 43079207d4 [parser] Parse a!?[0]
Fixes #41177.

Change-Id: I135f0b7aedbcb320ab0d1a1806b2ad3bedcda307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141886
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-04-01 07:33:01 +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 13dbe2a815 [parser] Correct precedence on ?[ when it's an index bracket operator
Fixes #40267.

Change-Id: I1929da0500f85f70dc241d969d05590a1e0c277e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138927
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-12 11:25:02 +00:00
Jens Johansen 47d462e8b1 [parser] Better handling of nullable types vs conditional expressions
Fixes #40834

Change-Id: I2fdad5a383c1873b1dd782b70e2f1e3ab8664b40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137960
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-03-03 09:49:57 +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 1b7b0bcc95 [parser] Allow covariant late final variables when it doesn't have an initializer
Bug: #40805
Change-Id: I94db171493ccb57f294928a3e2cec60740a09e91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137796
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-02 08:32:43 +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 991b522353 [CFE] Remove space from test filename
Change-Id: I0314708d14c24282c10b5ca545a30569f9a29025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137540
Reviewed-by: Jens Johansen <jensj@google.com>
2020-02-27 10:15:33 +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
Jens Johansen 201e6a86e1 [parser] Fix 'late' used as 'var'
Fixes #39858.

Change-Id: Ic2721fc56d184b3d0ad3082a7fa9cc45d6bbf45d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129060
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-01-10 10:46:17 +00:00
Jens Johansen b4a83427fd [parser] bang before type arguments
Fixes #39776.

Change-Id: If830e5d9d8fd68e98eb757f21e6c361fc496c931
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128402
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-01-10 09:53:19 +00:00
Jens Johansen e2d5aa352c [parser] Allow ?? after Type?
Fixes #39697.

Change-Id: I65c762304881038b205f1221d6cfdd1125ba71e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127890
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-12-12 06:59:53 +00:00
Jens Johansen 2a886d257f [parser] Allow '?.' and '?.[' after '!'
Fixes #39723

Change-Id: Ic98b7ddefcbbfefe33e6306b8fb4215419355f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127887
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-12-12 06:59:33 +00:00
Johnni Winther acff31ed26 [cfe] Support null-aware index access
Change-Id: I54b58624722845e4b008b90e675516ec274bc2da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125960
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-21 14:36:30 +00:00
Jens Johansen 12c92332f8 [CFE] Parser test can run scanner in non-nnbd-mode
Tests in the folder "non-nnbd" are run in non-nnbd mode.

Change-Id: I27c2acec93f729b76f024f12dcfb84f31903e0b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124688
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-11-11 11:43:07 +00:00
Jens Johansen 48f0b83ff2 [CFE] Allow ! in cascade
Fixes #39286.

Change-Id: I4e7270dacf7bc43accae4d45d26146cfb7d2b1ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124330
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-11 09:44:12 +00:00
Jens Johansen 5b7c981086 [CFE] Parser test framework also outputs token stream
This makes it much easier to see what the parser is actually working
with in the face of token stream rewrites.

Change-Id: Ic336f18fab7c8fd7a42020b32af4a480bbde25bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122865
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-28 10:25:30 +00:00
Jens Johansen 5c2b86897c [parser] late is a built-in identifier
Fixes #38803

Change-Id: I2fe7817aa0311c2370222a3205f1a1e02dc9aba4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-11 06:19:13 +00:00
Jens Johansen 0242dea803 [CFE] Amend parser test framework to include intertwined output
Add expect file that includes both listener trace and actual parser trace.

Change-Id: I7fe1a13429b80ac4ce315f8b9248ab984644fd14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119331
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-01 06:53:02 +00:00
Jens Johansen c3c31b74fd [parser] Fix bug wrt when the handleNonNullAssertExpression is added
This fix is basically a revert of the first fix for for the same issue,
https://github.com/dart-lang/sdk/commit/627e4c8cad17f069a9dc281e6726cc2080f1af45

Fix #37708

Bug: 37708
Change-Id: Ic470b2663e7171fcac6a8de3d9e1276b7815a64b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118574
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-09-27 11:53:15 +00:00
Jens Johansen acfda5d837 [CFE] Parser test framework
Change-Id: I1f27b380a2e6f8ea34d8ce66de6d581a1da8bf96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118572
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-09-26 08:40:08 +00:00