diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 4dca4fc4ada..f8252601a13 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -3080,20 +3080,20 @@ and GenUntupledArgsDiscardingLoneUnit cenv cgbuf eenv m numObjArgs curriedArgInf GenExpr cenv cgbuf eenv SPSuppress arg2 discard | _ -> (curriedArgInfos, args) ||> List.iter2 (fun argInfos x -> - GenUntupledArgExpr cenv cgbuf eenv m argInfos x Continue) + GenUntupledArgExpr cenv cgbuf eenv m argInfos x) /// Codegen arguments -and GenUntupledArgExpr cenv cgbuf eenv m argInfos expr sequel = +and GenUntupledArgExpr cenv cgbuf eenv m argInfos expr = let g = cenv.g let numRequiredExprs = List.length argInfos - assert (numRequiredExprs >= 1) - if numRequiredExprs = 1 then - GenExpr cenv cgbuf eenv SPSuppress expr sequel + if numRequiredExprs = 0 then + () + elif numRequiredExprs = 1 then + GenExpr cenv cgbuf eenv SPSuppress expr Continue elif isRefTupleExpr expr then let es = tryDestRefTupleExpr expr if es.Length <> numRequiredExprs then error(InternalError("GenUntupledArgExpr (2)", m)) es |> List.iter (fun x -> GenExpr cenv cgbuf eenv SPSuppress x Continue) - GenSequel cenv eenv.cloc cgbuf sequel else let ty = tyOfExpr g expr let locv, loce = mkCompGenLocal m "arg" ty @@ -3104,7 +3104,6 @@ and GenUntupledArgExpr cenv cgbuf eenv m argInfos expr sequel = let tys = destRefTupleTy g ty assert (tys.Length = numRequiredExprs) argInfos |> List.iteri (fun i _ -> GenGetTupleField cenv cgbuf eenvinner (tupInfoRef, loce, tys, i, m) Continue) - GenSequel cenv eenv.cloc cgbuf sequel ) @@ -3224,7 +3223,7 @@ and GenApp (cenv: cenv) cgbuf eenv (f, fty, tyargs, curriedArgs, m) sequel = // static extension method with empty arguments. | [[]], [_] when numObjArgs = 0 -> 0 // instance extension method with empty arguments. - | [[_];[]], [_;_] when numObjArgs = 1 -> 0 + | [[_];[]], [_;_] when numObjArgs = 0 -> 1 | _ -> numMethodArgs else numMethodArgs diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index a7e6fdfa37b..65d146cc581 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -2251,6 +2251,12 @@ module TypecheckTests = peverify cfg "pos36-srtp-app.exe" exec cfg ("." ++ "pos36-srtp-app.exe") "" + [] + let ``sigs pos38`` () = + let cfg = testConfig' "typecheck/sigs" + fsc cfg "%s --target:library -o:pos38.dll --warnaserror" cfg.fsc_flags ["pos38.fs"] + peverify cfg "pos38.dll" + [] let ``sigs pos23`` () = let cfg = testConfig' "typecheck/sigs" diff --git a/tests/fsharp/typecheck/sigs/pos38.fs b/tests/fsharp/typecheck/sigs/pos38.fs new file mode 100644 index 00000000000..bf9ad7ea8f9 --- /dev/null +++ b/tests/fsharp/typecheck/sigs/pos38.fs @@ -0,0 +1,28 @@ +module Pos38 + +type Expression = + | EndOp + | BinaryOp of Expression * Expression + +let mutable count = 0 + +[] +module Extensions = + + type Expression with + + member this.Foobar2 : unit = + match this with + | BinaryOp (_, e2) -> + e2.Foobar2 + | EndOp -> + count <- count + 1 + () + + +let c = BinaryOp(EndOp, EndOp) + +c.Foobar2 + +if count <> 1 then failwith "incorrect count" +