Skip to content

Unexpected FS3571 shorthand lambda atomic error #16457

@cmeeren

Description

@cmeeren
let call (f: string -> int) x = f x

let x = call _.Length ""

Expected behavior

Compiles.

Actual behavior

0>Program.fs(10,1): Error FS0010 : Incomplete structured construct at or before this point in expression
0>Program.fs(10,14): Error FS3571 : _. shorthand syntax for lambda functions can only be used with atomic expressions. That means expressions with no whitespace unless enclosed in parentheses.

Known workarounds

Enclose shorthand lambda in parentheses:

let x = call (_.Length) ""

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions