Uploaded image for project: 'Swift'
  1. Swift
  2. SR-456

Confusing build error when calling 'max' function within 'extension Int'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

      Xcode Version: Version 7.2 (7C68)
      OS X Version: 10.11.1 (15B42)

      Description

      When trying to build code that calls max() within an extension Int, a compiler error occurs.

      import Foundation
      
      
      func thisWorksCorrectly()
      {
          let maxValue = max(0, 1)
      }
      
      internal extension Int
      {
          static func thisDoesNotBuild()
          {
             // Error: Cannot call value of non-function type 'Int'
              let maxValue = max(0, 1)
          }
          
          static func butThisDoesBuild()
          {
              let maxValue = Swift.max(0, 1)
          }
      }
      

      This problem can be worked around by changing max(0, 1) to Swift.max(0, 1), but the error message seems unclear.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                kyleve Kyle Van Essen
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: