dotnet / dotnet/fsharp

Inconsistent analysis for top-level module in F# script

Open
#16,986 1 comment 2 reactions 1 assignee Claimed by @KevinRansom View on GitHub
Area-Diagnostics Bug
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

In the script files, the following code is analysed in the editor without any errors
```F#
module A

let x = 3
```

but if you send this code to the FSI in any way (IDE, `dotnet fsi file.fsx`, `dotnet fsi --use:file.fsx`)
`FS0010: Unexpected start of structured construct in definition. Expected '=' or other token.` error will occur

![image](https://github.com/dotnet/fsharp/assets/26364714/6b5dd0ca-c735-4186-8ace-29a83b059c12)
![image](https://github.com/dotnet/fsharp/assets/26364714/bd10e7be-5411-44ca-8337-d0cb75ceb5f6)
![image](https://github.com/dotnet/fsharp/assets/26364714/68fed1f5-3198-4c81-8333-39749f6224a6)

Either top-level modules must be allowed in execution with fsi, or the corresponding error must be shown when analyzed in the editor.

* .NET 8
* Rider 2024.1 RC 1, VS Code, `dotnet fsi`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.