Skip to content

Parser should report ambiguous givens syntax #22197

Open
@WojciechMazur

Description

@WojciechMazur

Compiler version

3.6

Minimized example

trait Arg
trait Ret

given what: () => Arg => Ret = ??? // error
// ambigious but not handled

given what1: () => (Arg => Ret) = ??? 
// implicit def what(): (Arg => Ret) = ???

given what2: (() => Arg) => Ret = ??? 
// implicit def what(ctx: () => Arg): Ret = ???

given what3: (() => Arg => Ret) = ???
// implicit lazy val: (() => Arg => Ret) = ???

Output Error/Warning message

-- Error: /Users/wmazur/projects/scala/sandbox/test.scala:4:22 ---------------------------------------------------------------------------------------------------------------------------------------------
4 |given what: () => Arg => Ret = ??? // error
  |                      ^^
  |                      end of toplevel definition expected but '=>' found

Why this Error/Warning was not helpful

No context on how to fix the code

Suggested improvement

Inform that given definition is ambigious, recommend placing using paranthesis to fix the expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:parserarea:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions