Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Fix FS3236 when taking the address of an untyped generalized `let` binding (e.g. `let ffff = ValueNone`) passed to an `inref` parameter. ([Issue #19608](https://github.com/dotnet/fsharp/issues/19608), [PR #19948](https://github.com/dotnet/fsharp/pull/19948))
* Fix `MethodAccessException` under `--realsig+` when a closure (inner `let rec`, `task`/`async` state machine, or quotation splice) inside a member defined in an intrinsic type augmentation (`type C with member ...`) accesses a `private` member of `C`. The synthesized closure is now nested inside the declaring type instead of beside it in the module class. ([Issue #19933](https://github.com/dotnet/fsharp/issues/19933), [PR #19955](https://github.com/dotnet/fsharp/pull/19955))
* Preserve source range for type errors on empty-bodied computation expressions (e.g. `foo {}`) in pipelines, function arguments, and type-annotated contexts, instead of reporting `unknown(1,1)`. ([Issue #19550](https://github.com/dotnet/fsharp/issues/19550), [PR #19849](https://github.com/dotnet/fsharp/pull/19849))
* Tooltip "Full name" now shows demangled companion module names (e.g. `MyType.func` instead of `MyTypeModule.func`). ([Issue #17335](https://github.com/dotnet/fsharp/issues/17335), [PR #19867](https://github.com/dotnet/fsharp/pull/19867))
Expand Down
7 changes: 7 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ module internal AddressOps =
checkTakeNativeAddress readonly
None, mkValAddr m readonly vref, readonly, writeonly

// LVALUE of a type-instantiated local value reference produced by TcVal for generalized let bindings.
| Expr.App(Expr.Val(vref, _, _), _, _, [], m) when MustTakeAddressOfVal g vref || CanTakeAddressOfImmutableVal g m vref mut ->
let readonly = not (MustTakeAddressOfVal g vref)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KirtiRamchandani : Can you please combine the two clauses together as separate |-or'd parts having shared when condition and shared body? Should work as long as they both bind vref and m values.

let writeonly = false
checkTakeNativeAddress readonly
None, mkValAddr m readonly vref, readonly, writeonly

// LVALUE of "e.f" where "f" is an instance F# field or record field.
| Expr.Op(TOp.ValFieldGet rfref, tinst, [ objExpr ], m) when
MustTakeAddressOfRecdFieldRef rfref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,32 @@ let test () =
|> shouldSucceed

[<Fact>]
let ``Issue 18841 - plain let discard with no address-of still compiles`` () =
let ``Issue 19608 - address of untyped ValueNone compiles`` () =
Fsx """
module Test

type S =
struct
val Field: int
end
let x (y: inref<ValueOption<int>>) = ()

let test () =
let s = S()
let _ = s
let ffff = ValueNone
x &ffff
"""
|> asExe
|> compile
|> shouldSucceed

[<Fact>]
let ``Issue 19608 - native address of untyped ValueNone binding fails`` () =
Fsx """
#nowarn "51"

module Test

let test () =
let ffff = ValueNone
let _ = &&ffff
()
"""
|> typecheck
|> shouldSucceed
|> shouldFail
|> withErrorCode 256
Loading