Not sure if bug...
...but I set it to the fsbugs e-mail anyway.
Let's start with this F# code:
module Test.Component | |
// After the Haskell type | |
type public Either<'TFault, 'TSuccess> = | |
| Left of 'TFault | |
| Right of 'TSuccess | |
with | |
[<CompiledName("ForEvery")>] | |
static member iter (fault : 'TFault -> unit) (fix : 'TSuccess -> unit) (value : Either<'TFault, 'TSuccess>) = | |
match value with | |
| Left a -> fault a | |
| Right b -> fix b | |
[<CompiledName("ForEach")>] | |
static member iter0 = | |
Either<'TFault, 'TSuccess>.iter ignore | |
[<CompiledName("ToOption")>] | |
static member toOption (value:Either<'TFault, 'TSuccess>) = | |
match value with | |
| Right y -> Some y | |
| _ -> None | |
end |
The last function maps to C# as
namespace Test | |
{ | |
[CompilationMapping(SourceConstructFlags.Module)] | |
public static class Component | |
{ | |
[DebuggerDisplay("{__DebugDisplay(),nq}"), CompilationMapping(SourceConstructFlags.SumType)] | |
[Serializable] | |
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] | |
public abstract class Either<TFault, TSuccess> : IEquatable<Component.Either<TFault, TSuccess>>, IStructuralEquatable, IComparable<Component.Either<TFault, TSuccess>>, IComparable, IStructuralComparable | |
{ | |
... | |
[CompilationSourceName("toOption")] | |
public static FSharpOption<TSuccess> ToOption(Component.Either<TFault, TSuccess> value) | |
{ | |
if (value is Component.Either<TFault, TSuccess>.Right) | |
{ | |
Component.Either<TFault, TSuccess>.Right right = (Component.Either<TFault, TSuccess>.Right)value; | |
TSuccess y = right.item; | |
return FSharpOption<TSuccess>.Some(y); | |
} | |
return null; | |
} | |
... | |
} | |
} | |
} |
Now change the initial F# line to be namespace
rather than module
...
File1.fs(9,18): error FS0755: The 'CompiledName' attribute cannot be used with this language element File1.fs(15,18): error FS0755: The 'CompiledName' attribute cannot be used with this language element File1.fs(19,18): error FS0755: The 'CompiledName' attribute cannot be used with this language element
So for comparison purposes, let's replace CompiledName
with Obsolete
, and see what we've built...
namespace Test.Component | |
{ | |
[DebuggerDisplay("{__DebugDisplay(),nq}"), CompilationMapping(SourceConstructFlags.SumType)] | |
[Serializable] | |
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] | |
public abstract class Either<TFault, TSuccess> : IEquatable<Either<TFault, TSuccess>>, IStructuralEquatable, IComparable<Either<TFault, TSuccess>>, IComparable, IStructuralComparable | |
{ | |
... | |
[Obsolete("ToOption")] | |
public static FSharpOption<TSuccess> toOption(Either<TFault, TSuccess> value) | |
{ | |
if (value is Either<TFault, TSuccess>.Right) | |
{ | |
Either<TFault, TSuccess>.Right right = (Either<TFault, TSuccess>.Right)value; | |
TSuccess y = right.item; | |
return FSharpOption<TSuccess>.Some(y); | |
} | |
return null; | |
} | |
... | |
} | |
} | |
where I can't for th |
where I can't for the life of me see the difference.
This happens when building using the latest compiler release in either VS2008 shell or VS2010 shell; or from the command line using MSBuild for either .net3.5 or 4.
No comments :
Post a Comment