![](https://csdnimg.cn/release/download_crawler_static/10464206/bg10.jpg)
Dart Programming Language Specification 12
error must be reported by a Dart compiler before the erroneous code is executed.
A Dart implementation has considerable freedom as to when compilation
takes place. Modern programming language implementations often interleave
compilation and execution, so that compilation of a method may be delayed,
e.g., until it is first invoked. Consequently, compile-time errors in a method m
may be reported as late as the time of m’s first invocation.
As a web language, Dart is often loaded directly from source, with no inter-
mediate binary representation. In the interests of rapid loading, Dart implemen-
tations may choose to avoid full parsing of method bodies, for example. This can
be done by tokenizing the input and checking for balanced curly braces on method
body entry. In such an implementation, even syntax errors will be detected only
when the method needs to be executed, at which time it will be compiled (JITed).
In a development environment a compiler should of course report compilation
errors eagerly so as to best serve the programmer.
If an uncaught compile-time error occurs within the code of a running isolate
A, A is immediately suspended. The only circumstance where a compile-time
error could be caught would be via code run reflectively, where the mirror system
can catch it.
Typically, once a compile-time error is thrown and A is suspended, A will
then be terminated. However, this depends on the overall environment. A Dart
engine runs in the context of an embedder, a program that interfaces between the
engine and the surrounding computing environment. The embedder will often
be a web browser, but need not be; it may be a C++ program on the server for
example. When an isolate fails with a compile-time error as described above,
control returns to the embedder, along with an exception describing the problem.
This is necessary so that the embedder can clean up resources etc. It is then the
embedder’s decision whether to terminate the isolate or not.
Static warnings are those errors reported by the static checker. They have no
effect on execution. Many, but not all, static warnings relate to types, in which
case they are known as static type warnings. Static warnings must be provided
by Dart compilers used during development such as those incorporated in IDEs
or otherwise intended to be used by developers for developing code. Compilers
that are part of runtime execution environments such as virtual machines should
not issue static warnings.
Dynamic type errors are type errors reported in checked mode.
Run-time errors are exceptions raised during execution. Whenever we say
that an exception ex is raised or thrown, we mean that a throw expression (16.9)
of the form: throw ex; was implicitly evaluated or that a rethrow statement
(17.10) of the form rethrow was executed. When we say that a C is thrown,
where C is a class, we mean that an instance of class C is thrown.
If an uncaught exception is thrown by a running isolate A, A is immediately
suspended.
8 Variables
variables