swiftlang / swift

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

[SR-4444] Shadowing and order dependency #47021

Open dabrahams opened 7 years ago

dabrahams commented 7 years ago
Previous ID SR-4444
Radar rdar://problem/31361075
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | @DougGregor | |Priority | Medium | md5: abbfddf007840ef5c25c485539424782

relates to:

Issue Description:

with

$ git fetch https://github.com/dabrahams/swift refs/bugs/shadowing-order-dependence:BUG && git checkout BUG

Build swift, then run the Prototypes/AU3.swift test:

-*- mode: compilation; default-directory: "/scp:halsted:/Users/dave/src/s/swift/test/Prototypes/" -*-
Compilation started at Thu Mar 30 17:07:46

rm -rf /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp && mkdir -p /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp && /Users/Shared/dabrahams/s/swift/utils/gyb -DWORD_BITS=64 /Users/Shared/dabrahams/s/swift/test/Prototypes/AU3.swift.gyb -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift && /Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift -- xcrun --toolchain default --sdk /Applications/Xcode-8E161.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/k9/nzq6k4f57xb5vw8wrgk_7cvh0000gn/T/swift-testsuite-clang-module-cache1bLYIW' -F /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks -Xlinker -rpath -Xlinker /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks  -swift-version 3  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out -Onone -g && /Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift --  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out "--stdlib-unittest-in-process" "--stdlib-unittest-filter" "ViewValueSemantics"
Could not cast value of type 'a.AnyUInt16UnicodeView.Adapter<a.RandomAccessUnicodeView<Swift.Array<Swift.UInt16>>>' (0x7fc25c012ce0) to 'a.AnyUInt16UnicodeView.Adapter<a.RandomAccessUnicodeView<Swift._UTF16StringStorage>>' (0x7fc25c015cf0).
StdlibUnittest: using filter: ViewValueSemantics
[ RUN      ] AnyUnicode.ViewValueSemantics

Compilation exited abnormally with code 250 at Thu Mar 30 17:08:12

Now take the declaration of protocol UnicodeView and move it to the top of the test file. Now the test will pass. I think the generic init of AnyUInt16UnicodeView on line 546 is looking up "UnicodeView" and finding it in the standard library instead of in this module.

Other hashes:

clang                              a4170877a0 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                        ccc20796d Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llbuild                            b696a76 Merge pull request #&#8203;134 from hughbe/wsl-expected
lldb                               ca932e489 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llvm                               808ed5e711d Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
ninja                              0b0374e Merge pull request #&#8203;1255 from tchajed/bind-localhost
swift                              ba2b68f921 Merge pull request #&#8203;8436 from milseman/wip_strings_prototype
swift-corelibs-foundation          a6e77b4 Merge pull request #&#8203;924 from ianpartridge/nsregularexpression
swift-corelibs-libdispatch         d137aa4 Makes the DispatchIO initializer that accepts a path failable, reflecting the fact that a relative or non-existent path is invalid.
swift-corelibs-xctest              50cc074 XCTestAssertNoThrow (#184)
swift-integration-tests            8ae3586 Merge pull request #&#8203;18 from apple/disable-lldb-test
swift-xcode-playground-support     9e980f2 Temporary disable test to get the incremental bot blue again
swiftpm                            6d416488 [Workspace] Move root constraints out of DependencyManifests
dabrahams commented 7 years ago

@swift-ci create

belkadan commented 7 years ago

Likely comes from the way main source files are parsed in chunks. I didn't think we were type-checking them in chunks too, but maybe that's how we forbid the unsafe forward references.