Commit Graph

5 Commits

Author SHA1 Message Date
Peter von der Ahé 57ac8b1ad9 Remove redundant instrumentation from tests and expectations.
Remove instrumentation for diagnostic messages, forwarding stubs and
covariance, since all this information is present in the expectation
files already.

Change-Id: Idf6622f7eddba801761e13666b470ae6dcc9d59b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97106
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-03-20 06:52:13 +00:00
Paul Berry c800a1cc29 Fix error recovery for invalid assignment.
Previously, the front end recovered from an invalid assignment by
producing an "as" expression, e.g.:

    int x;
    String y;
    x = y;

Would produce an "invalid assignment" error, as well as this kernel
code:

    int x;
    String y;
    x = y as{TypeError} int;

The rationale was that the "as" check was guaranteed to fail, so this
code would produce a runtime error at the correct location.  However,
there were two problems:

1. (Minor problem) the "as" doesn't actually fail if the RHS is null.

2. (Major problem) for type inference, the type of an assignment
expression is defined to be the type of the RHS.  This means that if
the invalid assignment gets used for type inference, we generate
mal-typed kernel code, e.g.:

    int x;
    String y;
    var z = (x = y);

Gets compiled to:

    int x;
    String y;
    String z = (x = y as{TypeError} int);

This CL addresses both problems by changing the kernel representation
so that it evaluates the RHS and then throws an exception.  Since a
"throw" expression has type Bottom, the kernel representation is
guaranteed to be properly typed.  This also ensures that an exception
gets thrown if the RHS is null.  Finally, as a side bonus, it makes
the error-recovered kernel code more similar to the kernel code we
generate in other error recovery scenarios.

Change-Id: Iac74e0c726ce029ac0560d271413e85c15bfec5c
Reviewed-on: https://dart-review.googlesource.com/24140
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-12-04 14:38:04 +00:00
Paul Berry abe2e85d15 Report "invalid assignment" from the front end as an error rather than a warning.
The front end only detects invalid assignments during type inference,
and type inference is only done in strong mode.  In strong mode,
invalid assignment is an error.

Change-Id: I1c598716be84804e9dc109414fe45f73888ed8c0
Reviewed-on: https://dart-review.googlesource.com/20741
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-11-14 18:39:14 +00:00
Paul Berry cd49cf1201 Insert implicit downcasts for compound assignments.
Change-Id: I090594e16fa890864775b2ebc58842d861c134a4
Reviewed-on: https://dart-review.googlesource.com/18517
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-03 22:07:10 +00:00
Paul Berry c4e00daf70 Create a front_end test case for invalid assignment errors.
Change-Id: I5c23f7eb6d07b551397ca2301ed5485910083b8d
Reviewed-on: https://dart-review.googlesource.com/18140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-01 22:09:27 +00:00