Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-525] AnyObject unresolved dot expr fails oddly and intermittently #43142

Closed
swift-ci opened this issue Jan 12, 2016 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-525
Radar None
Original Reporter emanuel (JIRA User)
Type Bug
Environment

Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 85231a2)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 8c50fc5d55b963182e98f665a18862a0

relates to:

  • SR-524 AnyObject unresolved dot expr does not work across files in the same module

Issue Description:

Description:

When refactoring test cases, unresolved dot expr seems as if it's not typechecking properly. Swift reports an error message that doesn't seem to make sense. Sometime the type checking succeeds by including top level expressions that don't appear to affect the statement in question.

Inputs:

Replace swift/validation-test/stdlib/Dictionary.swift with the following content:

// RUN: rm -rf %t
// RUN: mkdir -p %t
//
// RUN: %S/../../utils/gyb %s -o %t/main.swift
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Dictionary -Xfrontend -disable-access-control
//
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-run %t/Dictionary
// REQUIRES: executable_test

// XFAIL: linux

import StdlibUnittest
import Foundation



var DictionaryTestSuite = TestSuite("Dictionary")

func getCOWSlowDictionary() {
  var d = Dictionary<TestKeyTy, TestValueTy>(minimumCapacity: 10)
}

//DictionaryTestSuite.test("deleteChainCollision") {

//}

//===---
// NSDictionary -> Dictionary bridging tests.
//===---


func getAsNSMutableDictionary(d: Dictionary<Int, Int>) -> NSMutableDictionary {
  let keys = Array(d.keys.map { TestObjCKeyTy($0) })
  let values = Array(d.values.map { TestObjCValueTy($0) })

  return NSMutableDictionary(objects: values, forKeys: keys)
}

func getBridgedVerbatimDictionaryAndNSMutableDictionary()
    -> (Dictionary<NSObject, AnyObject>, NSMutableDictionary) {
  let nsd = getAsNSMutableDictionary([ 10: 1010, 20: 1020, 30: 1030 ])
  return (_convertNSDictionaryToDictionary(nsd), nsd)
}

DictionaryTestSuite.test("BridgedFromObjC.Verbatim.DictionaryIsCopied") {
  var (d, nsd) = getBridgedVerbatimDictionaryAndNSMutableDictionary()

  // Find an existing key.
  do {
    var kv = d[d.indexForKey(TestObjCKeyTy(10))!]
    kv.1.value == 1010
  }
}

runAllTests()

Then run this test case using lit, for example:

../llvm/utils/lit/lit.py -a ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/stdlib/Dictionary.swift

It results in the error message:

/swift/swift/validation-test/stdlib/Dictionary.swift:52:16: error: binary operator '==' cannot be applied to operands of type '_' and 'Int'
    kv.1.value == 1010
    ~~~~~~~~~~ ^  ~~~~

where the underscore appears to be a type variable.

Uncommenting the empty delete chain collision test case causes this test case to pass like so:

[ RUN      ] Dictionary.deleteChainCollision
[       OK ] Dictionary.deleteChainCollision
[ RUN      ] Dictionary.BridgedFromObjC.Verbatim.DictionaryIsCopied
[       OK ] Dictionary.BridgedFromObjC.Verbatim.DictionaryIsCopied
Dictionary: All tests passed

This is odd because that statement should have no affect on the typing of other code in the module, but it appears to.

Results while minimizing this example oscillate back and forth between working and not. This is the smallest that I seem to easily be able to make this. Making it smaller still produces a version that consistently fails with the provided error message. Minimizing it even more produces an entirely different error message, which is reported in SR-524.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis
Copy link
Collaborator

I cannot reproduce this, and judging by the example, the reason it once errored out is a mystery, to say the least. Closing w/o a regression test because there is little to no value in trying to reduce it to something palatable at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants