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

analyzer doesn't warn about missing main method #20030

Closed
peter-ahe-google opened this issue Jul 14, 2014 · 8 comments
Closed

analyzer doesn't warn about missing main method #20030

peter-ahe-google opened this issue Jul 14, 2014 · 8 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-as-intended Closed as the reported issue is expected behavior

Comments

@peter-ahe-google
Copy link
Contributor

The following language tests fail:

main_not_a_function_test/01
main_test/03
no_main_test/01

@bwilkerson
Copy link
Member

Removed Priority-Unassigned label.
Added Priority-Medium label.

@bwilkerson
Copy link
Member

I don't understand why any of these should produce an error/warning. Could you please point me to the section(s) in the specification where they are defined?


Set owner to @peter-ahe-google.
Added NeedsInfo label.

@peter-ahe-google
Copy link
Contributor Author

I guess the specification is unclear about these situations leading to warnings. I've filed issue #21521.


Added Triaged label.

@peter-ahe-google
Copy link
Contributor Author

Marked this as being blocked by #21521.

@lrhn
Copy link
Member

lrhn commented Nov 7, 2014

The part of the spec mentioning "main" is the Script section.
The current LaTeX version in the repository requires:

  • A runtime error if the library doesn't have a declared or imported top-level function called "main".
  • A static warning if "main" has more than two required parameters.
  • and, implied by the way it's called, a runtime error if "main" requires more than two parameters (it's called with zero, one or two positional parameters, depending on how many it allows, and if it requires more than two, it's still called with two, causing the error).

The requirement that "main" is a top-level function disallows things like:
  var main = () { print("Hello world!"); }
  var main = new CallableObject();
  var main = new ObjectWithNoSuchMethod();
which could otherwise have allowed "main(arg1, arg2)" to succeed.

(The VM allows all three examples).

@peter-ahe-google
Copy link
Contributor Author

"- and, implied by the way it's called, a runtime error if "main" requires
more than two parameters (it's called with zero, one or two positional
parameters, depending on how many it allows, and if it requires more than
two, it's still called with two, causing the error)."

I'm not sure how to reach that conclusion from the actual text in the specification.

@bwilkerson
Copy link
Member

The part of the spec mentioning "main" is the Script section.

Correct. But what distinguishes a script from a library? In other words, how should the analyzer decide that a file is a script as well as a library and that this requirement therefore applies?

@bwilkerson
Copy link
Member

Unless someone wants to continue the discussion, I'm closing this issue.


Added AsDesigned label.

@peter-ahe-google peter-ahe-google added Type-Defect area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-as-intended Closed as the reported issue is expected behavior labels Feb 25, 2015
@peter-ahe-google peter-ahe-google self-assigned this Feb 25, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. closed-as-intended Closed as the reported issue is expected behavior
Projects
None yet
Development

No branches or pull requests

3 participants