Skip to content

Commit 8e4c2d6

Browse files
parloughCommit Queue
authored and
Commit Queue
committed
[vm] Fix link to learn more about missing main function
The previous link no longer lead to a relevant destination. While I can add a client-side redirect on dart.dev, this CL updates the link to a redirect we can better guarantee as up to date in the long term. TEST=vm/cc/DartAPI_RootLibraryMissingMain Change-Id: I1e9dbf7a32c1468c308e9cf00d96575ba3c24695 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373322 Reviewed-by: Slava Egorov <[email protected]> Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent d06fb0c commit 8e4c2d6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

runtime/vm/dart_api_impl.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5440,8 +5440,7 @@ DART_EXPORT Dart_Handle Dart_LoadScriptFromKernel(const uint8_t* buffer,
54405440
if (tmp.IsNull()) {
54415441
return Api::NewError(
54425442
"Invoked Dart programs must have a 'main' function defined:\n"
5443-
"https://dart.dev/guides/language/"
5444-
"language-tour#a-basic-dart-program");
5443+
"https://dart.dev/to/main-function");
54455444
}
54465445
library ^= tmp.ptr();
54475446
IG->object_store()->set_root_library(library);

runtime/vm/dart_api_impl_test.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7488,6 +7488,19 @@ TEST_CASE(DartAPI_RootLibrary) {
74887488
EXPECT(Dart_IsNull(root_lib)); // Root library did change.
74897489
}
74907490

7491+
TEST_CASE(DartAPI_RootLibraryMissingMain) {
7492+
const char* kScriptChars =
7493+
"notMain() {"
7494+
" return 12345;"
7495+
"}";
7496+
7497+
Dart_Handle result = LoadScript(TestCase::url(), kScriptChars);
7498+
7499+
EXPECT_ERROR(result,
7500+
"Invoked Dart programs must have a 'main' function defined:\n"
7501+
"https://dart.dev/to/main-function");
7502+
}
7503+
74917504
TEST_CASE(DartAPI_LookupLibrary) {
74927505
const char* kScriptChars =
74937506
"import 'library1_dart';"

0 commit comments

Comments
 (0)