-
Notifications
You must be signed in to change notification settings - Fork 803
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
Improve error reporting: using EntryPoint attribute in an F# script #1431
Comments
Agreed. |
@anton-pt can you suggest an error message that should be displayed - we should be able to come up with one easily, and then this can be marked as up for grabs. |
How about something like this? Warning: defined function [f] marked as EntryPoint was not invoked. Execute [f argv] in order to invoke [f] with the appropriate string array of command line arguments. |
It seems to me that FSI should implicitly run a method marked with the EntryPoint attribute. For example: [<EntryPoint>]
let main argv =
printfn "Hello, World!"
0 should be equivalent to let main argv =
printfn "Hello, World!"
0
main fsi.CommandLineArgs |
We already have an implicit entry point created in scripts, adding some different behaviour, based on attribute would be confusing and, probably, a breaking change, for example consider the following code: [<EntryPoint>]
let main argv =
printfn "Hello, World!"
0
#if INTERACTIVE
main fsi.CommandLineArgs
#endif
I think, a warning should be produced instead (as it was suggested originally). |
Yes, it makes sense |
If we're just looking for text here, working from @anton-pt 's suggestion:
I assume the [f] will be replaced with the fuction name. I think "argv" is confusing if the user needs to type args there, so the will hopefully inspire the programmer to type real values there. |
What
Running the code:
in FSI produces the output
val main : argv:string [] -> int
but doesn't actually invoke the function.
Why
Some beginners may be unsure about how F# scripts and FSI work and may run some code from an application which has an
EntryPoint
into FSI. This happened recently to a former colleague.How
Using the
EntryPoint
attribute in FSI should produce a compiler warning indicating that it won't be invoked automatically.The text was updated successfully, but these errors were encountered: