You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
6.0.400 compilation error with private types in namespace used in a different file #13661
changed the title [-]Compilation error with private types in namespace when upgrading to 6.0.400[/-][+]6.0.400 compilation error with private types in namespace used in a different file[/+]on Aug 10, 2022
The problem appears to go away with a CustomEquality for type ModuleOrNamespaceKind.
[<CustomEquality; NoComparison>]typeModuleOrNamespaceKind=/// Indicates that a module is compiled to a class with the "Module" suffix added. | FSharpModuleWithSuffix
/// Indicates that a module is compiled to a class with the same name as the original module | ModuleOrType
/// Indicates that a 'module' is really a namespace | Namespace of/// Indicates that the sourcecode had a namespace./// If false, this namespace was implicitly constructed during type checking.
isExplicit: bool
overridethis.Equals other =match other with|:? ModuleOrNamespaceKind as kind ->match this, kind with| FSharpModuleWithSuffix, FSharpModuleWithSuffix
| ModuleOrType, ModuleOrType
| Namespace _, Namespace _->true|_->false|_->falseoverridethis.GetHashCode()=match this with| FSharpModuleWithSuffix ->0| ModuleOrType ->1| Namespace _->2
Subtle introduction of the bug. Marking CompilationPath as NoEquality may help track track this down, looks like it is the structural equality on this:
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
Switching Accessibility and CompilationPath to NoEquality wouldn't really force the fix here since the equality comparison is performed directly on ModuleOrNamespaceKind.
We can mark that one as NoEquality but that will add quite a bit of extra equality code in different places. So I would lean more towards @nojaf 's custom equality there. Especially since I don't see a need for the current default version where a implicitly defined namespace is considered different than the same but explicitly defined one (though I might be wrong there).
Is there a chance we could get this fix rolled out soon? The SDK version 6.0.401 (released yesterday) is still failing to build our project even though the fix was merged one month ago.
Is there a chance we could get this fix rolled out soon? The SDK version 6.0.401 (released yesterday) is still failing to build our project even though the fix was merged one month ago.
Fix was only merged to .NET7 branch, we couldn't do servicing to 401, it was too late. One of future 6.x.x servicing is a target.
Activity
[-]Compilation error with private types in namespace when upgrading to 6.0.400[/-][+]6.0.400 compilation error with private types in namespace used in a different file[/+]vzarytovskii commentedon Aug 10, 2022
Looks like this suggestion been fixed
fsharp/fslang-suggestions#389
Let me bisect and find where it was changed.
vzarytovskii commentedon Aug 10, 2022
Ok, with help of @0101, we bisected to that PR: #13287
CC @nojaf @dsyme
nojaf commentedon Aug 11, 2022
@vzarytovskii I can't really put my finger on it.
For some reason the
Blahtype is not being added tofsharp/src/Compiler/Checking/NameResolution.fsi
Line 215 in bdb6462
and it is later not found in
fsharp/src/Compiler/Checking/NameResolution.fs
Line 3311 in bdb6462
nojaf commentedon Aug 11, 2022
The problem appears to go away with a
CustomEqualityfortype ModuleOrNamespaceKind.@vzarytovskii
vzarytovskii commentedon Aug 11, 2022
Huh, interesting. Do did lookup work before?
nojaf commentedon Aug 11, 2022
I could be way off here but I think some structure that contains a
ModuleOrNamespaceKindis being compared somewhere.For example:
fsharp/src/Compiler/TypedTree/TypedTree.fs
Lines 503 to 528 in bdb6462
dsyme commentedon Aug 11, 2022
Subtle introduction of the bug. Marking
CompilationPathasNoEqualitymay help track track this down, looks like it is the structural equality on this:dsyme commentedon 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
Also this in AccessibilityLogic:
One option is to switch to
NoEqualityandNoComparisononAccessibilityandCompilationPathand 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
0101 commentedon Aug 15, 2022
This particular case seems to be caused by the comparison made here:
fsharp/src/Compiler/TypedTree/TypedTreeBasics.fs
Lines 443 to 450 in 5420f09
But I imagine it could also cause a similar issue here:
fsharp/src/Compiler/Symbols/Symbols.fs
Lines 125 to 132 in 5420f09
Switching
AccessibilityandCompilationPathtoNoEqualitywouldn't really force the fix here since the equality comparison is performed directly onModuleOrNamespaceKind.We can mark that one as
NoEqualitybut that will add quite a bit of extra equality code in different places. So I would lean more towards @nojaf 's custom equality there. Especially since I don't see a need for the current default version where a implicitly defined namespace is considered different than the same but explicitly defined one (though I might be wrong there).stroborobo commentedon Sep 14, 2022
Is there a chance we could get this fix rolled out soon? The SDK version 6.0.401 (released yesterday) is still failing to build our project even though the fix was merged one month ago.
vzarytovskii commentedon Sep 14, 2022
Fix was only merged to .NET7 branch, we couldn't do servicing to 401, it was too late. One of future 6.x.x servicing is a target.
stroborobo commentedon Sep 14, 2022
Ok, thanks for the quick response. We'll have to hold out another month or two then. :'(
vzarytovskii commentedon Sep 14, 2022
Yeah, sorry for that, was a bit unfortunate timing on our side.