Skip to content

Expressions other than properties/method calls/indexing are allowed after _. in dot-lambdas #16136

@brianrourkeboll

Description

@brianrourkeboll

Expressions other than properties/method calls/indexing are allowed after _. in dot-lambdas (see fsharp/fslang-suggestions#506, fsharp/fslang-design#710). I think this is a bug in #13907, unless there's something I'm missing from fsharp/fslang-design#710.

Repro steps

  1. Write a dot-lambda and put a literal or most any other atomic expression after the dot. This effectively means any arbitrarily-complex expression, as long as it's parenthesized.
  2. _.expr compiles as fun _ -> expr, i.e., basically fun x -> ignore x; expr.
let _ = _.3
let _ = _.1e-04
let _ = _."🙃"
let _ = _.[||]
let _ = _.{||}
let _ = _.typeof<int>
let _ = _.null
let _ = _.__SOURCE_DIRECTORY__
let _ = _.(<@ 1 @>)
let _ = _.(nameof nameof)
let _ = _.struct (1, 2, 3)
let _ = _.{ new System.IDisposable with member _.Dispose () = () }
let _ = _.(while true do ())
let _ = _.(let x = 3 in x + x)

Expected behavior

This was surprising to me. I would have expected only properties, method calls, or indexing to be allowed.

Actual behavior

Any arbitrary expression can be used on the right-hand side of a dot-lambda (_.).

Known workarounds

N/A.

Related information

This is in main and in the latest .NET 8 SDK.

Metadata

Metadata

Assignees

Labels

BugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.Regression

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions