-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dart2js: support main with an argument #14200
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
Comments
Do we have any tests for this yet? Added this to the M8 milestone. |
corelib/main_test.dart does minimal checking that you do not fall over when you write a main with arguments. It is unclear to me how I would write a test using our harness which would pass some arguments to the test execution. |
Yeah, my worry was that our harness doesn't allow testing this. Maybe that's something we can fix though. Allowing a test like this: // Options: foo bar would allow us to make progress. We'll have to figure out what it means in a browser context. cc @ricowind. |
Why is this critical? What is "args"? Might that argument contain useful information, or will it simply be null? Is there a type that would be appropriate? |
I have written a test for this, using the DartOptions feature of the test harness. The old version also had the supression, because dart2js compilation does not accept the arguments on the DartOptions line anyway: |
Where is this behavior specified? |
This comment was originally written by @seaneagan What's wrong with For command line apps, issue #12272 would provide a more convenient way to access args. For browser apps, the URI pretty much acts as the command line, so a similar approach could be taken with the "route" package. |
If you want to leak the main arguments, just create a global variable and store it there. So nothing is lost by just giving it to main. We don't like the new Options().arguments for several reasons: it is only in dart:io which means only server, and it shouldn't be necessary to allocate a new object (which is due to historic limitations). |
FWIW, this would simplify use of command-line arguments in the implementation of dart2js. I'm all for this change, it just needs to be specified somewhere. "Florian can expand on this if needed." is a bit too vague. |
This is now blocking the dart:isolate refactoring. We work around it with the following patch, but it breaks dart2js when isolate support is not enabled: it passes in |
Please coordinate with floitsch and fix this asap. Set owner to [email protected]. |
This comment was originally written by [email protected] Fixed in https://codereview.chromium.org/43723002/. Added Fixed label. |
Both main() and main(args) are valid signatures for the main entry point into an isolate. Florian can expand on this if needed.
The text was updated successfully, but these errors were encountered: