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

Null reference exception in compiler when referencing duplicate type defined in another project #16970

Open
brianrourkeboll opened this issue Mar 29, 2024 · 0 comments
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Triage-Investigate
Milestone

Comments

@brianrourkeboll
Copy link
Contributor

brianrourkeboll commented Mar 29, 2024

When a project has two types with the same name in the same namespace defined in two separate files, and the second of the two definitions is referenced in another project, I see error FS0193: internal error: Object reference not set to an instance of an object, indicating a null reference exception somewhere in the compiler. If I reference the first definition, I get error FS0039: The value or constructor 'T1' is not defined. I would expect the latter error in both cases.

Repro steps

Provide the steps required to reproduce the problem:

  1. Create two projects, e.g., project A and project B.
  2. Reference project A in project B.
  3. Create two types with the same name in the same namespace in project A.
  4. Reference the second type definition in project B (call a method on it, use a constructor, etc.).
  5. Get error FS0193: internal error: Object reference not set to an instance of an object.

Minimal repro: https://gist.github.com/brianrourkeboll/169502b7cd20ec41f84a59cc0559b4b4

A/T1.fs

namespace A

type T = T1

A/T2.fs

namespace A

type T = T2

B/Program.fs

open A

let _ = T1 // FS0039: The value or constructor 'T1' is not defined.
let _ = T2 // FS0193: internal error: Object reference not set to an instance of an object.

Expected behavior

I would expect to see error FS0249: Two type definitions named 'T' occur in namespace 'A' in two parts of this assembly in project A and error FS0039: The value or constructor 'T1' is not defined in project B when referencing either of the duplicate types.

Actual behavior

I do see error FS0249: Two type definitions named 'T' occur in namespace 'A' in two parts of this assembly in project A, but I see error FS0193: internal error: Object reference not set to an instance of an object when I reference the second of the two duplicate types in project B.

Related information

I see this in Visual Studio 17.9.3 and 17.10.0 Preview 2, as well as in VS Code with Ionide with .NET SDK 8.0.202. I'm not sure how long this behavior has been around.

@github-actions github-actions bot added this to the Backlog milestone Mar 29, 2024
@abonie abonie added Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Triage-Investigate and removed Needs-Triage labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Triage-Investigate
Projects
Status: New
Development

No branches or pull requests

2 participants