Skip to content

Commit

Permalink
Merge pull request #10085 from dotnet/merges/main-to-release/dev16.8
Browse files Browse the repository at this point in the history
Merge main to release/dev16.8
  • Loading branch information
cartermp authored Sep 6, 2020
2 parents ae8c298 + 2bfdb79 commit cac462e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/fsharp/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)


Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions tests/fsharp/tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,12 @@ module TypecheckTests =
peverify cfg "pos36-srtp-app.exe"
exec cfg ("." ++ "pos36-srtp-app.exe") ""

[<Test>]
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"

[<Test>]
let ``sigs pos23`` () =
let cfg = testConfig' "typecheck/sigs"
Expand Down
28 changes: 28 additions & 0 deletions tests/fsharp/typecheck/sigs/pos38.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Pos38

type Expression =
| EndOp
| BinaryOp of Expression * Expression

let mutable count = 0

[<AutoOpen>]
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"

0 comments on commit cac462e

Please sign in to comment.