Skip to content

Weird action at a distance beyond parentheses #17790

Closed
@ByteEater-pl

Description

@ByteEater-pl

I can't do Seq(0).sortBy(_.abs)(0). That's understandable – the (0) isn't understood as indexing but a second parameter list (implicit) for sortBy, expected to contain a value of type Ordering[Int]. The common remedy is to explicitly reach for apply, thus: Seq(0).sortBy(_.abs) apply 0. I thought I could guide the compiler to get my intention with a pair of parentheses: (Seq(0).sortBy(_.abs))(0). But no – it gives the same error message as without. What helps is ({Seq(0).sortBy(_.abs)})(0).

Additionally, rejection of {Seq(0).sortBy(_.abs)}(0) as invalid syntax also seems a wart. And the message in this case is perplexing both in worksheet mode:

; expected but ( found

and in normal mode:

end of toplevel definition expected but '(' found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions