question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

6.0.400 compilation error with private types in namespace used in a different file

See original GitHub issue

Repro steps

Defining a private type in a namespace and using it in a module in another file in the same namespace leads to a compilation error in 6.0.400.

Compiles without error in 6.0.300.

A simple repro can be found here: https://github.com/l3m/fsharp-error-repro

Expected behavior

Unclear if the behavior in 6.0.300 or 6.0.400 is the actually correct one, but it’s certainly a change.

So the expectation would have been that it compiles in 6.0.400

Actual behavior

Fails to compile in 6.0.400

Known workarounds

Replace

type private Blah = ... 

with

type internal Blah = ... 

Related information

Observed on both linux and windows, with dotnet sdk 6.0.300 and 6.0.400

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
dsymecommented, Aug 11, 2022

By using this diff https://github.com/dotnet/fsharp/compare/main...dsyme:cwe?expand=1 it looks like these are the origin points for structural equality


let isPublicVal (lv: Val) = (lv.Accessibility = taccessPublic)
let isPublicUnionCase (ucr: UnionCaseRef) = (ucr.UnionCase.Accessibility = taccessPublic)
let isPublicRecdField (rfr: RecdFieldRef) = (rfr.RecdField.Accessibility = taccessPublic)
let isPublicTycon (tcref: Tycon) = (tcref.Accessibility = taccessPublic)

Also this in AccessibilityLogic:

        | AccessibleFrom(cs1, tc1), AccessibleFrom(cs2, tc2) -> (cs1 = cs2) && (match tc1, tc2 with None, None -> true | Some tc1, Some tc2 -> tyconRefEq g tc1 tc2 | _ -> false)

One option is to switch to NoEquality and NoComparison on Accessibility and CompilationPath and use an explicit equality routine in the above places.

Another is to use the custom equality like @nojaf above, though I think perhaps just making everything more explicit is better. There are enough notions of equality needed in the compiler its better to be explicit for anything in TypedTree

0reactions
vzarytovskiicommented, Sep 14, 2022

Ok, thanks for the quick response. We’ll have to hold out another month or two then. 😢

Yeah, sorry for that, was a bit unfortunate timing on our side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't see a class in the same namespace in different file at ...
But now whenever I try to compile I get a compiler error reporting that "The type or namespace name 'Data' could not be...
Read more >
NuGet Restore task fails for .Net Core project migrated with ...
Afterwards the build fails with the error: ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.
Read more >
Compiler Error CS1527
In this article ... Elements defined in a namespace cannot be explicitly declared as private, protected, protected internal or private protected.
Read more >
NET 6.0 - CRUD API Example and Tutorial
Tutorial on how to build a .NET 6.0 API that supports CRUD operations.
Read more >
How to Reverse Engineer a Unity Game
A “-” namespace: The sample game doesn't use namespaces in its code, but other projects can have a list here of the different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found