diff --git a/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs b/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs index 071fc474a18..74ee68565e2 100644 --- a/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs +++ b/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs @@ -194,12 +194,10 @@ module Pass1_DetermineTLRAndArities = let nFormals = vss.Length let nMaxApplied = GetMaxNumArgsAtUses xinfo f let arity = Operators.min nFormals nMaxApplied - if atTopLevel then - Some (f, arity) - else if arity<>0 || not (isNil tps) then - Some (f, arity) - else - None + if atTopLevel then Some (f, arity) + elif g.realsig && arity > 0 then None // This needs some investigation I sorta understand but would have a hard time explaining it + elif arity<>0 || not (isNil tps) then Some (f, arity) + else None /// Check if f involves any value recursion (so can skip those). /// ValRec considered: recursive && some f in mutual binding is not bound to a lambda