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

Macros expand even if their arguments contain erroneous trees

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.0
    • Component/s: Macros
    • Labels:
      None

      Description

      Typers.scala
      // begin adapt
      tree.tpe match {
        ...
        case _ =>
          ...
          else if (inExprModeButNot(mode, FUNmode) && tree.symbol != null && tree.symbol.isMacro && !tree.isDef) {
            val expansion = expandMacro(tree)
            if (expansion.isErroneous) expansion else typed(expansion, mode, pt)
          } else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode)) {
            ...
          }
      }
      

      Even if tree.exists(_.isErroneous), macro expansion logic still gets triggered by adapt. Moreover, in this case context.hasErrors is false. Is this okay?

        Activity

        Show
        Eugene Burmako added a comment - Fixed by https://github.com/scala/scala/commit/2fe570291a41e2701f3118bc0f643a9fa60c476b

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development