dotnet / dotnet/fsharp

Can't #load recursive namespaces into FSI

Open
#13,516 2 comments 0 reactions 0 assignees View on GitHub
Area-FSI Bug Impact-Medium
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

A file with a recursive namespace reference can't be loaded in FSI. This is similar to [#237](https://github.com/dotnet/fsharp/issues/237).

It _does_ compile as part of a project.

**Steps to reproduce:**

1. Create a file named "test.fs" containing:
```fsharp
namespace rec FakeNamespaceName

module AType =

type InnerType =
member x.AMethod: FakeNamespaceName.AType2 = { AField = "test" }

type AType2 = { AField: string }
```
2. Load the file in FSI:
```
#load "test.fs"
```

**Expected behavior**

The file is loaded into FSI.

**Actual behavior**

FSI gives this error:
test.fs(6,25): error FS0039: The namespace or module 'FakeNamespaceName' is not defined.

**Known workarounds**

* Don't use recursive namespaces with FSI
* Compile the code into an assembly and load that into FSI

**Related information**

Provide any related information (optional):
* Microsoft (R) F# Interactive version 12.0.4.0 for F# 6.0

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.