Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/fsharp/MethodCalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,15 @@ let AdjustCallerArgForOptional tcFieldInit eCallerMemberName (infoReader: InfoRe
if isOptCallerArg then errorR(Error(FSComp.SR.tcFormalArgumentIsNotOptional(), m))
assignedArg

// For non-nullable, non-optional arguments no conversion is needed.
// We return precisely the assignedArg. This also covers the case where there
// can be a lingering permitted type mismatch between caller argument and called argument,
// specifically caller can by `byref` and called `outref`. No coercion is inserted in the
// expression tree in this case.
| NotOptional when not (isNullableTy g calledArgTy) ->
if isOptCallerArg then errorR(Error(FSComp.SR.tcFormalArgumentIsNotOptional(), m))
assignedArg

| _ ->

let callerArgExpr2 =
Expand All @@ -1183,7 +1192,7 @@ let AdjustCallerArgForOptional tcFieldInit eCallerMemberName (infoReader: InfoRe
if isNullableTy g calledArgTy then
MakeNullableExprIfNeeded infoReader calledArgTy callerArgTy callerArgExpr m
else
callerArgExpr
failwith "unreachable" // see case above

| CallerSide dfltVal ->
let calledArgTy = calledArg.CalledArgumentType
Expand Down
15 changes: 13 additions & 2 deletions tests/fsharp/tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,20 @@ module CoreTests =
begin
use testOkFile = fileguard cfg "test.ok"

fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"]
fsc cfg "%s -o:test.exe -g --langversion:4.7" cfg.fsc_flags ["test.fsx"]

singleNegTest cfg "test"
singleVersionedNegTest cfg "4.7" "test"
exec cfg ("." ++ "test.exe") ""

testOkFile.CheckExists()
end

begin
use testOkFile = fileguard cfg "test.ok"

fsc cfg "%s -o:test.exe -g --langversion:5.0" cfg.fsc_flags ["test.fsx"]

singleVersionedNegTest cfg "5.0" "test"

exec cfg ("." ++ "test.exe") ""

Expand Down