Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM: `main` receives an argument which is not a `List<String>` #36626

Closed
eernstg opened this Issue Apr 15, 2019 · 4 comments

Comments

Projects
None yet
4 participants
@eernstg
Copy link
Member

eernstg commented Apr 15, 2019

[Edit: This problem exists with dart2js, #36627, but when I tested "the same thing" with the vm and created this issue, I accidentally mixed up two versions of the test program. It should of course be args is List<String>, and it does return true on the vm, so there is no vm issue after all. Corrected the code below.]

Cf. dart-lang/dart-pad#1009, the vm invokes the main function of a script with an argument which is not of type List<String>.

main(args) {
  // Corrected code: There is no problem.
  print(args is List<String>); // Prints 'true'.
}

The specification requires that it is a List<String>, here, and this would also be a reasonable choice in practice.

@eernstg eernstg changed the title `main` receives an argument which is not a `List<String>` VM: `main` receives an argument which is not a `List<String>` Apr 15, 2019

@jamesderlin

This comment has been minimized.

Copy link
Contributor

jamesderlin commented Apr 16, 2019

If I add print('${args.runtimeType}');, it prints List<String>. Huh?

@rmacnak-google

This comment has been minimized.

Copy link
Member

rmacnak-google commented Apr 16, 2019

You mean

main(args) {
  print(args is List<String>); // Prints 'true'.
}
@jamesderlin

This comment has been minimized.

Copy link
Contributor

jamesderlin commented Apr 17, 2019

Sorry, my last comment might not have been clear. When I run:

main(args) {
  print(args.runtimeType is List<String>);
  print('${args.runtimeType}');
}

I get:

false
List<String>

which makes no sense.

(Dart VM version: 2.2.1-dev.4.2.flutter-None (Fri Apr 12 00:16:17 2019 +0000) on "linux_x64")

@eernstg

This comment has been minimized.

Copy link
Member Author

eernstg commented Apr 17, 2019

@jamesderlin wrote:

makes no sense

I mixed up two versions of the test program, the vm works correctly. So this issue should just remain closed, there is nothing to report.

You should test args is List<String> as @rmacnak-google said, and it does return true. Testing args.runtimeType is T is true if and only if T is a supertype of Type, so it's false as tested.

But the problem does exist for dart2js, cf. #36627.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.