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

Improve error messages for *Dynamic signature mismatches

    Details

      Description

      import language.dynamics
      
      class X(val i: Int) extends Dynamic {
         def selectDynamic(name: Int) = i
      }
      
      object F {
         val x = new X(3)
         val z = x.y
      }
      
      F.scala:17: error: type mismatch;
       found   : String("y")
       required: Int
              val z = x.y
                      ^
      

      A better error message would indicate that selectDynamic has the wrong signature. A related situation is when selectDynamic has no arguments, which gives this error message:

      error: Int does not take parameters
          val z = x.y
                  ^
      

        Activity

        Hide
        Josh Suereth added a comment -

        Bumping to critical since this situation will probably happen frequently to those new to Dynamic.

        Show
        Josh Suereth added a comment - Bumping to critical since this situation will probably happen frequently to those new to Dynamic.
        Hide
        Grzegorz Kossakowski added a comment -

        Nada promised to take a look.

        Show
        Grzegorz Kossakowski added a comment - Nada promised to take a look.
        Show
        Grzegorz Kossakowski added a comment - Fixed in https://github.com/scala/scala/pull/1343

          People

          • Assignee:
            Nada Amin
            Reporter:
            Mark Harrah
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development