Commit Graph

62 Commits

Author SHA1 Message Date
Dan Rubel a02662c47e improve errors and recovery for factory methods
Change-Id: I55711bdb0f98c0747c7055bebda173702c2c138f
Reviewed-on: https://dart-review.googlesource.com/16720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-26 21:21:00 +00:00
Dan Rubel 1c7c72c679 Refactor and update modifier warnings
* Extract parse modifiers
    into ModifierContext and ModifierRecoveryContext
* Recover gracefully given out-of-order modifiers
* Generate analyzer error codes
* Address comment in prior CL
    https://dart-review.googlesource.com/c/sdk/+/10760/1/pkg/front_end/lib/src/fasta/parser/parser.dart#436

There are several more modifier error codes that need to be added.
I will tackle those in a subsequent CL.

Change-Id: I61e9182e14fa9d45b35029013a645329e6cc54ab
Reviewed-on: https://dart-review.googlesource.com/11800
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-10-11 23:32:10 +00:00
Devon Carew 5883eb9904 Add a hint for strong-mode: false in the analysis options file.
Related to https://github.com/dart-lang/sdk/issues/30789

Bug:
Change-Id: I77c85e49001934ce49708cddc431a6c1a082d386
Reviewed-on: https://dart-review.googlesource.com/9789
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2017-09-29 23:03:16 +00:00
Dan Rubel 9527f37146 refactor parse import
* `as` clause and `deferred as` clause processing pushed
     into a new processImportPrefixOpt method.
* New handleImportPrefix event for communicating 
    `as` clause and `deferred as` clause to the listeners.
* Several new more detailed error messages for out of order
    clauses and keywords in the import directive.

Change-Id: I133842c7225403fa000ca1cf0e49af9f8a011386
Reviewed-on: https://dart-review.googlesource.com/8580
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-29 14:39:01 +00:00
Dan Rubel f0caee1b24 Improve import directive recovery and report analyzer errors
- New handleRecoverImport event
    for clauses in import directive that are out of order
- New error codes for
    Duplicate prefix
    Prefix after combinator

Change-Id: I0fea7ad4b4014a0b8578d3982e0515fe85044854
Reviewed-on: https://dart-review.googlesource.com/7980
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-27 12:56:46 +00:00
Konstantin Shcheglov 73c93a3a13 Revert "Report compile time errors when assert initializers fail."
This reverts commit 556b0284b3.

Until the specification wording about constants evaluation is clarified.

R=brianwilkerson@google.com, paulberry@google.com

Bug:
Change-Id: If5ff6dfbc5f8f724f657694a5e331b9fd07227fc
Reviewed-on: https://dart-review.googlesource.com/5280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-12 16:05:17 +00:00
Leaf Petersen 1c94f7a604 Reland and refactor fuzzy arrow hints.
This restores the functionality from https://codereview.chromium.org/3012593002/, with some small refactors.

The test breakage that caused the revert is fixed in https://codereview.chromium.org/3004143002/ .

Also adds a couple of drive by fuzzy arrow fixes.

BUG=
R=jmesserly@google.com

Review-Url: https://codereview.chromium.org/3006893002 .
2017-08-31 12:18:51 -07:00
Karl Klose d7a6ef9f64 Revert "Add a hint on static uses of fuzzy arrows."
This reverts commit 1f7c0d2c4c.

TBR=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/3004113002 .
2017-08-31 08:30:22 +02:00
Leaf Petersen 1f7c0d2c4c Add a hint on static uses of fuzzy arrows.
This causes the analyzer to emit a hint message when fuzzy arrow
subtyping is used.

BUG=
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/3012593002 .
2017-08-30 15:27:26 -07:00
Dan Rubel 8786656783 map fasta error codes to analyzer
Rather than have multple fine grained error codes for each type
of modifier in each situation, this CL adds a new analyzer
ParserErrorCode.EXTRANEOUS_MODIFIER parallel to the fast parser
error code and updates the AstBuilder to generate that error
rather than ParserErrorCode.ABSTRACT_CLASS_MEMBER.

My goal is to review each analyzer error code similar to
ParserErrorCode.ABSTRACT_CLASS_MEMBER and map each to the same
ParserErrorCode.EXTRANEOUS_MODIFIER error code.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2999303002 .
2017-08-25 09:00:18 -04:00
Konstantin Shcheglov 556b0284b3 Report compile time errors when assert initializers fail.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/3003363002 .
2017-08-24 14:48:15 -07:00
Dan Rubel d1385f099f support class native clause
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2996163002 .
2017-08-22 07:42:56 -04:00
Devon Carew 69afd51bbe Add a hint to rename .analysis_options files.
BUG=
R=brianwilkerson@google.com, danrubel@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2993323002 .
2017-08-09 11:48:37 -07:00
Brian Wilkerson 471b7fd568 Emit a hint when using generic method comment syntax (issue 30356)
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2990383002 .
2017-08-08 09:12:26 -07:00
Brian Wilkerson defb2990d2 Add a test to ensure that error codes are not being missed and add missed error codes
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2992243002 .
2017-08-04 07:45:46 -07:00
Erik Ernst 9336e199fd Re-land of CL 2990703002, adding fixes to analyzer_test and error_test.
This CL is identical to the reverted CL 2990703002 which implements
syntactic support for generalized void in the analyzer, plus two bug
fixes in pkg/analyzer/test/generated/parser_test.dart and
pkg/analyzer_cli/test/error_test.dart. In the former, a test on parsing
`void,` was changed to expect an error: _isTypeIdentifier on a lone
`void` will no longer return true, which is necessary because `void`
can now be used as a type annotation alone. Another test on `void x`
was added, which produces the behavior previously seen for `void,`.
In error_test, the error which is used throughout was changed from
`void foo;` to `var int foo;` (because the former is no longer an
error).

Review-Url: https://codereview.chromium.org/2992623002 .
2017-07-27 12:39:19 +02:00
Erik Ernst 2e73ce1187 Revert "Implemented support for generalized void in analyzer."
This reverts commit 1d44f5296a,
because it causes failures for the analyzer in parser_test, error_test.

Review-Url: https://codereview.chromium.org/2990723002 .
2017-07-26 18:18:04 +02:00
Erik Ernst 1d44f5296a Implemented support for generalized void in analyzer.
Changed the analyzer parser to accept usages of `void` which were
previously rejected as syntax errors: `void` can now be the type
annotation for a variable or parameter, and it can be an actual type
argument.

Removed affected error codes like VOID_PARAMETER, VOID_VARIABLE,
VOID_RETURN_FOR_GETTER and associated declarations (like checking
functions), and adjusted test cases to expect success rather than
compile time errors.

Adjusted generalized_void_syntax_test.dart (it had real errors like
`final` variables with no initializer etc. that were not detected
when tools would just reject the file as syntactically wrong).

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2990703002 .
2017-07-26 17:45:13 +02:00
Florian Loitsch 377093841f Report an error when a part-of refers to an unnamed library.
Fixes #28522
BUG= http://dartbug.com/28522
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2931893004 .
2017-06-09 21:08:26 +02:00
Alexandre Ardhuin 617d0f53b6 add hint for @required (#29828) 2017-06-09 06:36:50 -07:00
danrubel d675a7c375 update errorCodeValues
Add the new fasta Scanner error codes to the errorCodeValues list
and add a test to ensure that any new error codes will also be added.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2932483002 .
2017-06-08 12:35:53 -04:00
Konstantin Shcheglov 19353f9e63 Issue 29358. Fix for reporting constant errors while evaluating constructor invocations.
We should not report errors in one file using offsets of node in
another file.

R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/29358

Review-Url: https://codereview.chromium.org/2825813002 .
2017-04-18 12:13:23 -07:00
Konstantin Shcheglov 62320cc838 Issue 25558. Report an error, but don't crash when AST it too deep.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25558

Review-Url: https://codereview.chromium.org/2823993002 .
2017-04-17 14:46:55 -07:00
Brian Wilkerson 3dcf0e31c5 Split error code to ease future improvements
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2813553006 .
2017-04-11 13:35:38 -07:00
Konstantin Shcheglov 9b701ae3da Add ParserErrorCode.INVALID_CONSTRUCTOR_NAME to the list of all error codes.
We need this for AnalysisDriver to be able to deserialize this error.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2780833002 .
2017-03-28 10:30:59 -07:00
Konstantin Shcheglov 27ab6478b9 Report errors for the new top-level inference rules.
We also stop type inference most of these cases with task based analysis.
Summary based analysis is not changed yet.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2782533002 .
2017-03-28 09:41:04 -07:00
Brian Wilkerson 4f28d97ac2 Add error checking for the immutable annotation (issue 27750)
R=pquitslund@google.com

Review-Url: https://codereview.chromium.org/2775863004 .
2017-03-24 11:56:24 -07:00
Brian Wilkerson ccf768144f More generic function type cases working
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2770143002 .
2017-03-24 08:08:23 -07:00
Brian Wilkerson 97cc40e0a7 Add strong mode error for mixins defining conflicting private names (issue 28809)
R=vsm@google.com

Review-Url: https://codereview.chromium.org/2738113002 .
2017-03-22 08:42:30 -07:00
Konstantin Shcheglov 571aae42b8 Issue 25733. Built-in itentifiers are not permitted as prefixes.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25733

Review-Url: https://codereview.chromium.org/2735193002 .
2017-03-07 10:16:45 -08:00
Brian Wilkerson 44148ec0a4 Revert "Add error for mixins defining conflicting private names (issue 28809)"
Review-Url: https://codereview.chromium.org/2716133002 .
2017-02-25 07:50:42 -08:00
Brian Wilkerson 12b6f249f3 Add error for mixins defining conflicting private names (issue 28809)
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2716453006 .
2017-02-25 07:27:58 -08:00
Konstantin Shcheglov 94556d578d Remove AnalysisErrorWithProperties and ErrorProperty.
It was not used in Analysis Server for some time, and we cannot use
it for any practical purpose with the new analysis driver.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2706123002 .
2017-02-20 15:13:42 -08:00
Brian Wilkerson 1bd630f4a2 Fix stack overflow printing recursive function types (issue 28835)
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2707983002 .
2017-02-20 11:37:08 -08:00
Paul Berry c9b692e8d9 Add a temporary analyzer error to work around #28515
Analyzer summaries do not yet support generic function-typed
parameters.  To avoid user confusion, generate an error if the user
tries to use a generic function-typed parameter.

The error can be worked around by using a typedef or changing generic
types to `dynamic`.

R=brianwilkerson@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2656303004 .
2017-01-29 07:35:03 -08:00
Konstantin Shcheglov 919d70d0cb Issue 28100. Implement new strong mode instantiate to bound rules in analyzer.
R=leafp@google.com, brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/28100

Review-Url: https://codereview.chromium.org/2640143007 .
2017-01-23 10:12:32 -08:00
Florian Loitsch 9a0ccfc092 Deprecate the use of Function as a class.
Shows a hint when `Function` is used:
- as a class name,
- in an extends clause,
- in a with clause.

The `Function` may or may not point to the core's `Function`. All uses of `Function` in these contexts are deprecated.

R=brianwilkerson@google.com

Committed: https://github.com/dart-lang/sdk/commit/4e6e72b0b0bc1558ea0ba695363c6dc8bf9433f5

Reverted: https://github.com/dart-lang/sdk/commit/3f871ae76f5269b50e531c61038727a074301990
Review-Url: https://codereview.chromium.org/2643073002 .
2017-01-23 17:34:09 +01:00
Florian Loitsch 5616882833 Revert "Deprecate the use of Function as a class."
This reverts commit 4e6e72b0b0.

BUG=

Review-Url: https://codereview.chromium.org/2650763002 .
2017-01-23 17:09:16 +01:00
Florian Loitsch 4e6e72b0b0 Deprecate the use of Function as a class.
Shows a hint when `Function` is used:
- as a class name,
- in an extends clause,
- in an implements clause,
- in a with clause.

The `Function` may or may not point to the core's `Function`. All uses of `Function` in these contexts are deprecated.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2643073002 .
2017-01-23 16:39:04 +01:00
Brian Wilkerson c40ec27266 Get the rest of the shared tests for covariant to pass
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2642683006 .
2017-01-20 15:04:50 -08:00
Brian Wilkerson fba8298923 Add missed error code
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2641383002 .
2017-01-20 10:58:35 -08:00
Konstantin Shcheglov c7487dfaea Issue 28100. In strong mode verify that TypeParameter bound has required type arguments.
R=brianwilkerson@google.com, leafp@google.com
BUG= https://github.com/dart-lang/sdk/issues/28100

Review-Url: https://codereview.chromium.org/2641213002 .
2017-01-19 13:25:48 -08:00
Brian Wilkerson d06a2326f1 Add parser support for covariant parameters
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2639883005 .
2017-01-19 09:38:35 -08:00
Brian Wilkerson e7577172d1 Add preliminary parser support for generic function types
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2628973003 .
2017-01-12 07:00:24 -08:00
Konstantin Shcheglov 0377beb128 Update 'Add final field formal parameters' Quick Fix to support the new analysis driver.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2618923003 .
2017-01-06 14:34:49 -08:00
Brian Wilkerson e22a2b4626 Enable messages in asserts by default
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2557513008 .
2016-12-07 12:23:00 -08:00
Brian Wilkerson 13933e9363 Add another missing error code
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2553443002 .
2016-12-04 16:03:08 -08:00
Konstantin Shcheglov 6f98b89877 Add ResolverErrorCode to errorCodeValues.
It might be these codes that caused the failure worked around in https://github.com/dart-lang/sdk/commit/5ff8db3a5f75b699ead93a9ffdb8998b9608c505

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2544883007 .
2016-12-03 13:59:30 -08:00
Konstantin Shcheglov c3e2c45cb3 Extract 'computeMissingOverrides' in ErrorVerifier.
So, we can reuse it in Quick Fixes.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2541153002 .
2016-11-30 14:04:43 -08:00
Paul Berry 0c928771fc Revert "Connect analyzer's AnalysisError object to front_end's CompilationError."
This reverts commit fc5270df72.

TBR=scheglov@google.com, brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2503803003 .
2016-11-15 10:00:34 -08:00