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

When using EntryPoint attribute in fsx script top-level code is not executed #13350

Open
0101 opened this issue Jun 22, 2022 · 0 comments
Open
Labels
Area-FSI Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@0101
Copy link
Contributor

0101 commented Jun 22, 2022

Let bindings still work, but side-effects are not executed.

Repro steps

script.fsx :

printfn "Hello world"

[<EntryPoint>]
let main _ = 0

dotnet fsi script.fsx

Expected behavior

We see Hello world printed, as it is when there is no [<EntryPoint>] used (sharplab - no EntryPoint).

Actual behavior

Nothing is printed. (sharplab - with EntryPoint)

Known workarounds

Don't use [<EntryPoint>] in scripts - as it's not executed anyway, see #1431

Considerations

Using [<EntryPoint>] in a script could just raise an error which would resolve this issue. It would cause a breaking change though for scripts that are imported from other scripts, because this currently works as expected:

script1.fsx:

let hello = printfn "Hello %s"

[<EntryPoint>]
let main _ = 0

script2.fsx:

#load "script1.fsx"
open Script1

hello "world"

dotnet fsi script2.fsx prints "Hello world"

@0101 0101 added the Bug label Jun 22, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 22, 2022
@vzarytovskii vzarytovskii added this to the Backlog milestone Jun 22, 2022
@dsyme dsyme added the Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. label Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FSI Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
Status: New
Development

No branches or pull requests

3 participants