Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brianrourkeboll opened this issue Oct 17, 2023 · 0 comments
Assignees
Labels
Bug Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Milestone

Comments

@brianrourkeboll
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Projects
Archived in project
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants