swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.58k stars 10.36k forks source link

[SR-4742] <<error type>> in diagnostic #47319

Open dabrahams opened 7 years ago

dabrahams commented 7 years ago
Previous ID SR-4742
Radar rdar://problem/31906401
Original Reporter @dabrahams
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, DiagnosticsQoI, TypeChecker | |Assignee | None | |Priority | Medium | md5: a284888fee2d7ca08cd511f09eef5fe9

Issue Description:

Against 8ecc3e31cf7 from github/master, build the attached for this, which probably indicates a type checker bug

xcrun --toolchain default --sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./bin/swiftc -target x86_64-apple-macosx10.9  -module-cache-path '/var/folders/8v/9769m3ps7ds7h9pg23lzcls00000gn/T/swift-testsuite-clang-module-cacherClZu6' -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks  -swift-version 3  /Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift -swift-version 4 -g -Onone -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/UnicodeDecoders && /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/UnicodeDecoders
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:616:1: error: type 'Unicode.UTF8.ReverseDecoder' (aka 'UTF8.ReverseDecoder') does not conform to protocol '_UTFDecoder'
extension Unicode.UTF8.ReverseDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:588:16: note: candidate has non-matching type 'UTF8.ReverseDecoder.Buffer' (aka '_UIntBuffer<UInt32, UInt8>')
    public var buffer = Buffer()
               ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:651:8: note: candidate has non-matching type '() -> (UTF8.ReverseDecoder.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)' (aka '() -> (_UIntBuffer<UInt32, UInt8>, consumedCodeUnits: UInt8, isValid: Bool)')
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:616:1: error: type 'Unicode.UTF8.ReverseDecoder' (aka 'UTF8.ReverseDecoder') does not conform to protocol 'UnicodeDecoder'
extension Unicode.UTF8.ReverseDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:522:7: note: protocol requires property 'buffer' with type '_UIntBuffer<UInt32, <<error type>>.CodeUnit>'; do you want to add a stub?
  var buffer: Buffer { get set }
      ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:523:8: note: protocol requires function '_parseMultipleCodeUnits()' with type '() -> (<<error type>>.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)'; do you want to add a stub?
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<Encoding.EncodedScalar>
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:271:18: note: protocol requires nested type 'Encoding'; do you want to add it?
  associatedtype Encoding : _UnicodeEncodingBase
                 ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:721:1: error: type 'Unicode.UTF8.ForwardDecoder' (aka 'UTF8.ForwardDecoder') does not conform to protocol '_UTFDecoder'
extension Unicode.UTF8.ForwardDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:581:16: note: candidate has non-matching type 'UTF8.ForwardDecoder.Buffer' (aka '_UIntBuffer<UInt32, UInt8>')
    public var buffer = Buffer()
               ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:754:8: note: candidate has non-matching type '() -> (UTF8.ForwardDecoder.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)' (aka '() -> (_UIntBuffer<UInt32, UInt8>, consumedCodeUnits: UInt8, isValid: Bool)')
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:721:1: error: type 'Unicode.UTF8.ForwardDecoder' (aka 'UTF8.ForwardDecoder') does not conform to protocol 'UnicodeDecoder'
extension Unicode.UTF8.ForwardDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:522:7: note: protocol requires property 'buffer' with type '_UIntBuffer<UInt32, <<error type>>.CodeUnit>'; do you want to add a stub?
  var buffer: Buffer { get set }
      ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:523:8: note: protocol requires function '_parseMultipleCodeUnits()' with type '() -> (<<error type>>.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)'; do you want to add a stub?
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<Encoding.EncodedScalar>
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:271:18: note: protocol requires nested type 'Encoding'; do you want to add it?
  associatedtype Encoding : _UnicodeEncodingBase
                 ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:852:1: error: type 'UTF16.ReverseDecoder' does not conform to protocol '_UTFDecoder'
extension UTF16.ReverseDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:838:16: note: candidate has non-matching type 'UTF16.ReverseDecoder.Buffer' (aka '_UIntBuffer<UInt32, UInt16>')
    public var buffer: Buffer
               ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:865:8: note: candidate has non-matching type '() -> (UTF16.ReverseDecoder.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)' (aka '() -> (_UIntBuffer<UInt32, UInt16>, consumedCodeUnits: UInt8, isValid: Bool)')
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:852:1: error: type 'UTF16.ReverseDecoder' does not conform to protocol 'UnicodeDecoder'
extension UTF16.ReverseDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:522:7: note: protocol requires property 'buffer' with type '_UIntBuffer<UInt32, <<error type>>.CodeUnit>'; do you want to add a stub?
  var buffer: Buffer { get set }
      ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:523:8: note: protocol requires function '_parseMultipleCodeUnits()' with type '() -> (<<error type>>.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)'; do you want to add a stub?
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<Encoding.EncodedScalar>
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:271:18: note: protocol requires nested type 'Encoding'; do you want to add it?
  associatedtype Encoding : _UnicodeEncodingBase
                 ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:880:1: error: type 'Unicode.UTF16.ForwardDecoder' (aka 'UTF16.ForwardDecoder') does not conform to protocol '_UTFDecoder'
extension Unicode.UTF16.ForwardDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:832:16: note: candidate has non-matching type 'UTF16.ForwardDecoder.Buffer' (aka '_UIntBuffer<UInt32, UInt16>')
    public var buffer: Buffer
               ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:885:8: note: candidate has non-matching type '() -> (UTF16.ForwardDecoder.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)' (aka '() -> (_UIntBuffer<UInt32, UInt16>, consumedCodeUnits: UInt8, isValid: Bool)')
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:880:1: error: type 'Unicode.UTF16.ForwardDecoder' (aka 'UTF16.ForwardDecoder') does not conform to protocol 'UnicodeDecoder'
extension Unicode.UTF16.ForwardDecoder : _UTFDecoder {
^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:522:7: note: protocol requires property 'buffer' with type '_UIntBuffer<UInt32, <<error type>>.CodeUnit>'; do you want to add a stub?
  var buffer: Buffer { get set }
      ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:523:8: note: protocol requires function '_parseMultipleCodeUnits()' with type '() -> (<<error type>>.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)'; do you want to add a stub?
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<Encoding.EncodedScalar>
       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:271:18: note: protocol requires nested type 'Encoding'; do you want to add it?
  associatedtype Encoding : _UnicodeEncodingBase
                 ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:627:56: error: binary operator '-' cannot be applied to operands of type 'Int' and 'UInt8'
      _storage: s.byteSwapped >> (type(of: s).bitWidth - bitCount),
                                  ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:627:56: note: overloads for '-' exist with these partially matching parameter lists: (UInt8, UInt8), (Int, Int)
      _storage: s.byteSwapped >> (type(of: s).bitWidth - bitCount),
                                                       ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:636:12: error: use of unresolved identifier 'ParseResult'
    return ParseResult(
           ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:646:12: error: use of unresolved identifier 'ParseResult'
    return ParseResult(
           ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:659:16: error: cannot use mutating member on immutable value: 'self' is immutable
        return _consumeValidCodeUnits(2)
               ^~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:651:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:669:16: error: cannot use mutating member on immutable value: 'self' is immutable
        return _consumeValidCodeUnits(3)
               ^~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:651:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:681:16: error: cannot use mutating member on immutable value: 'self' is immutable
        return _consumeValidCodeUnits(4)
               ^~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:651:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:684:12: error: cannot use mutating member on immutable value: 'self' is immutable
    return _parseInvalid()
           ^~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:651:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:695:16: error: use of unresolved identifier 'invalid'
        return invalid(codeUnitCount: 2)
               ^~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:705:16: error: use of unresolved identifier 'invalid'
        return invalid(codeUnitCount: 2)
               ^~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:714:16: error: use of unresolved identifier 'invalid'
        return invalid(codeUnitCount: 3)
               ^~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:717:12: error: use of unresolved identifier 'invalid'
    return invalid(codeUnitCount: 1)
           ^~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:739:12: error: use of unresolved identifier 'ParseResult'
    return ParseResult(
           ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:740:25: error: use of unresolved identifier 'codeUnitCount'
      _consumeCodeUnits(codeUnitCount, consumedCodeUnits: n, isValid: true))
                        ^~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:748:9: error: cannot use mutating member on immutable value: 'self' is immutable
    _ = _consumeCodeUnits(n)
        ^~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:745:12: note: mark method 'mutating' to make 'self' mutable
  internal func _consumeInvalidCodeUnits(
           ^
           mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:749:12: error: use of unresolved identifier 'ParseResult'
    return ParseResult(
           ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:762:16: error: cannot use mutating member on immutable value: 'self' is immutable
        return _consumeValidCodeUnits(2)
               ^~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:754:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:771:16: error: cannot use mutating member on immutable value: 'self' is immutable
        return _consumeValidCodeUnits(3)
               ^~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:754:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:782:16: error: cannot use mutating member on immutable value: 'self' is immutable
        return _consumeValidCodeUnits(4)
               ^~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:754:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:785:12: error: cannot use mutating member on immutable value: 'self' is immutable
    return _parseInvalid()
           ^~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:754:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:797:41: error: missing argument label 'codeUnitCount:' in call
        return _consumeInvalidCodeUnits(2)
                                        ^
                                        codeUnitCount: 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:808:11: error: missing argument label 'codeUnitCount:' in call
          buffer._storage   & 0b0__1100_0000__0000_0000__0000_0000
          ^
          codeUnitCount: 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:812:12: error: cannot convert return expression of type 'Int' to return type '(UTF8.ForwardDecoder.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)' (aka '(_UIntBuffer<UInt32, UInt8>, consumedCodeUnits: UInt8, isValid: Bool)')
    return 1
           ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:871:24: error: cannot assign to property: 'self' is immutable
      buffer._bitCount = 0
      ~~~~~~           ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:865:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:872:14: error: use of unresolved identifier 'ParseResult'
      return ParseResult(s, consumedCodeUnits: 2, isValid: true)
             ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:874:21: error: left side of mutating operator isn't mutable: 'self' is immutable
    buffer._storage >>= 16; buffer._bitCount = 16
    ~~~~~~          ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:865:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:874:46: error: cannot assign to property: 'self' is immutable
    buffer._storage >>= 16; buffer._bitCount = 16
                            ~~~~~~           ^
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:865:3: note: mark method 'mutating' to make 'self' mutable
  func _parseMultipleCodeUnits() -> Unicode.ParseResult<EncodedScalar> {
  ^
  mutating 
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:875:12: error: use of unresolved identifier 'ParseResult'
    return ParseResult(
           ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:887:14: error: use of unresolved identifier 'ParseResult'
      return ParseResult(
             ^~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:891:12: error: cannot convert return expression of type '(Bool, Int)' to return type '(UTF16.ForwardDecoder.EncodedScalar, consumedCodeUnits: UInt8, isValid: Bool)' (aka '(_UIntBuffer<UInt32, UInt16>, consumedCodeUnits: UInt8, isValid: Bool)')
    return (false, 1*16)
           ^~~~~~~~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:934:28: error: type 'Codec.ForwardDecoder' has no member 'decode'
    let errorCount = Codec.ForwardDecoder.decode(
                     ~~~~~~^~~~~~~~~~~~~~ ~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:942:28: error: type 'Codec.ReverseDecoder' has no member 'decode'
    let errorCount = Codec.ReverseDecoder.decode(
                     ~~~~~~^~~~~~~~~~~~~~ ~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:968:28: error: type 'Codec.ForwardDecoder' has no member 'decode'
    let errorCount = Codec.ForwardDecoder.decode(
                     ~~~~~~^~~~~~~~~~~~~~ ~~~~~~
/Users/Shared/dabrahams/s/swift/test/Prototypes/UnicodeDecoders.swift:977:28: error: type 'Codec.ReverseDecoder' has no member 'decode'
    let errorCount = Codec.ReverseDecoder.decode(
                     ~~~~~~^~~~~~~~~~~~~~ ~~~~~~

Other hashes

clang                              e6d55005e6 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
cmark                              d875488 Merge pull request #&#8203;4 from llvm-beanz/generate-cmark-exports
compiler-rt                        3acb58590 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llbuild                            7853943 Merge pull request #&#8203;143 from neonichu/better-diagnostics-for-dependency-cycles
lldb                               6deeb29d5 Merge branch 'swift-4.0-branch' into stable
llvm                               8758fc3e9cc Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
Traceback (most recent call last):
dabrahams commented 7 years ago

@swift-ci create