Invalid code when decompiling simple F# not (isNull x) into C#
See original GitHub issueConsider this simple code:
open System
type C() =
member __.notNull x = not (isNull x)
It decompiles into that:
using Microsoft.FSharp.Core;
using System;
using System.Reflection;
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: FSharpInterfaceDataVersion(2, 0, 0)]
[CompilationMapping(SourceConstructFlags.Module)]
public static class _
{
[CompilationMapping(SourceConstructFlags.ObjectType)]
[Serializable]
public class C
{
public C() : this()
{
}
public bool notNull<a>(a x) where a : class
{
return x == null ? 1 : 0 == 0;
}
}
}
namespace <StartupCode$_>
{
internal static class $_
{
}
}
That statement return x == null ? 1 : 0 == 0
is very strange because it doesn’t compile in C#.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Apktool and dummy values (once for all) · Issue #2104
I: Using Apktool 2.3.2 W: Could not find sources I: Checking ... I try to decompile) is from a ROM (Evolution X 2.0)...
Read more >If Not IsNull in ASP Classic
To fix the code remove the = from the <% %> tags, like so; <% If Not IsNull(rs("ContractValue")) Then Response.
Read more >ISNULL formula not behaving as expected
I've tried testing with other null currency values and it still seems to be not working. IF(ISNULL(field__c), 1, 0). formula.
Read more >What does it mean to do a "null check" in C or C++?
Null checks (and other forms of Defensive Programming) clutter code up, and actually make it more error prone than other error-handling ...
Read more >What's New in EF Core 7.0
Improved SQL for simple Identity insert. The case above inserts a single row with an IDENTITY key column and no other database-generated values....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ForNeVeR Thanks for reporting! The decompilation is currently handled by an external component (ILSpy). The version I’m using is somewhat outdated – I’ll try updating to latest sometime later and I’ll let you know if they’ve fixed it.
Thanks for the fix and for the clarification. I’ve updated the ILSpy issue and reclassified it as an enhancement.
(Also I can confirm that the issue has been fixed.)