You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Section 19.1.2 Semantics of Imports says the following about top-level functions
For every top level function $f$ named \id{} in
\NamespaceName{\metavar{import},i},
a corresponding function named \id{} with the same signature as $f$.
% This error can occur because being-loaded is a dynamic property.
Calling the function results in a dynamic error,
and so does closurizing it
(\ref{functionClosurization}).
This seems to imply that checking whether library is loaded or not happens on invocation and we have test language/deferred/not_loaded_check_test which tries to test that during evaluation of an expression lib.f(sideEffect()) where lib is not loaded the following will happen:
sideEffect is executed
An Error is thrown.
However CFE implements a different semantics (ever since it started to support deferred loading, see CL): checking whether the library is loaded or not is done before arguments are evaluated.
Presumably, we can specify the semantics where the dynamic error occurs before any actual arguments are evaluated, because (IIUC) the CFE determines the behavior of all backends in this case. So we don't even have to consider making it an implementation specific behavior, or in any way allowing for both orderings.
Agree, the attempted access to any name through the deferred prefix should throw, as if prefix.name... was guarded by !prefix._loaded ? throw ...an error... : prefix.name....
(And I remembered the previous behavior before we fixed it to what it is today. Which was worse.)
I'm closing this, given that the language specification has been updated to match the implemented semantics. @mraleph, please reopen if you think there is more to do.
Section
19.1.2 Semantics of Imports
says the following about top-level functionsThis seems to imply that checking whether library is loaded or not happens on invocation and we have test
language/deferred/not_loaded_check_test
which tries to test that during evaluation of an expressionlib.f(sideEffect())
wherelib
is not loaded the following will happen:sideEffect
is executedError
is thrown.However CFE implements a different semantics (ever since it started to support deferred loading, see CL): checking whether the library is loaded or not is done before arguments are evaluated.
I suggest we update specification to match the implementation. Test update CL: https://dart-review.googlesource.com/c/sdk/+/338125
Related issue dart-lang/sdk#54151
The text was updated successfully, but these errors were encountered: