Scala Programming Language
  1. Scala Programming Language
  2. SI-2488

Positional argument should be allowed after named argument that is in its original position

    Details

      Description

      The following code ought to compile.

      def f(a: int, b: Int) = 0
      f(a = 4, 5)
      

        Activity

        Hide
        Andrew Gaydenko added a comment -

        From my ordinary Scala user's POV additional degree of freedom just complicate the code. For named arguments "all or nothing" rule seem more acceptable, IMHO.

        Show
        Andrew Gaydenko added a comment - From my ordinary Scala user's POV additional degree of freedom just complicate the code. For named arguments "all or nothing" rule seem more acceptable, IMHO.
        Hide
        Lukas Rytz added a comment -

        fixed in r19546

        Show
        Lukas Rytz added a comment - fixed in r19546
        Hide
        Jason Zaugg added a comment -

        The spec was not updated to reflect this change.

        Show
        Jason Zaugg added a comment - The spec was not updated to reflect this change.
        Hide
        Oleg Aleshko added a comment - - edited

        looks like the issue requires a bit more attention
        it still doesn't compile in case of several overloads and error message is really misleading:

        class c {def f(a:Int, b:Int) = 1; def f() = 1}
        new c().f(a=1,2)
        

        fails with

        <console>:18: error: overloaded method value f with alternatives:
          ()Int <and>
          (a: Int,b: Int)Int
         cannot be applied to (a: Int, Int)
                      new c().f(a=1,2)
        

        tested with 2.8.0, 2.9.1 and scala-2.10.0.r25912-b20111031024940

        Show
        Oleg Aleshko added a comment - - edited looks like the issue requires a bit more attention it still doesn't compile in case of several overloads and error message is really misleading: class c {def f(a:Int, b:Int) = 1; def f() = 1} new c().f(a=1,2) fails with <console>:18: error: overloaded method value f with alternatives: ()Int <and> (a: Int,b: Int)Int cannot be applied to (a: Int, Int) new c().f(a=1,2) tested with 2.8.0, 2.9.1 and scala-2.10.0.r25912-b20111031024940
        Show
        Lukas Rytz added a comment - fixed in https://github.com/scala/scala/commit/da994bc9ce2cd9394ccb994fad677a6c67ad2759 spec fixed in https://github.com/scala/scala-dist/commit/5b2fa4e3ca6c9ed27f6946934a03a1b1afbecf5d

          People

          • Assignee:
            Lukas Rytz
            Reporter:
            Gilles Dubochet
            TracCC:
            Andrew Gaydenko
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development