dotnet / dotnet/fsharp

Module marked with ModuleSuffix attribute is hidden by another module with the same name

Open
#3,565 6 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Area-Compiler-Checking-NameResolution Feature Improvement
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

If a project contains two modules with the same name, one of which is marked with `ModuleSuffix` attribute:

```fsharp
// Foo1.fs
namespace Library

[]
module Foo =
let bar x = x
```
```fsharp
// Foo2.fs
module Library.Foo

let buzz x = x
```
symbols defined in the marked with `ModuleSuffix` attribute one are not seen in projects referencing this one:

![image](https://user-images.githubusercontent.com/873919/30242962-7cb4eb4c-95a9-11e7-8496-0683b922fc38.png)

![image](https://user-images.githubusercontent.com/873919/30242970-96444f6c-95a9-11e7-8600-b97bfeea3a52.png)

The bug (feature?) was found while moving ExtCore library to .NET Standard 2.0

Minimal repro https://github.com/vasily-kirichenko/TwoModulesBug

It's compiled to (ILSpy):

```csharp
namespace Library
{
[CompilationMapping(SourceConstructFlags.Module)]
public static class Foo
{
public static a buzz(a x)
{
return x;
}
}
}

namespace Library
{
[CompilationMapping(SourceConstructFlags.Module), CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)]
public static class FooModule
{
public static a bar
(a x)
{
return x;
}
}
}
```

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.