apple / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.23k stars 1.12k forks source link

NSMutableArray.remove and NSMutableOrderedSet.remove fail to remove element on Linux #4928

Open LumingYin opened 3 months ago

LumingYin commented 3 months ago

As shown in the attached screenshot, NSMutableArray.remove fails to remove the specified element on Linux. This also affects NSMutableOrderedSet.remove, which is backed by NSMutableArray.

Screenshot 2024-03-27 at 3 46 06 PM

Swift Code used to reproduce the issue:

import Foundation

let s = NSMutableArray()
s.add(2)
s.remove(2)
print(s.description)

Full Terminal output:

root@c723e86e0fc3:~# uname -a
Linux c723e86e0fc3 6.2.0-1019-azure #19~22.04.1-Ubuntu SMP Wed Jan 10 22:57:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
root@c723e86e0fc3:~# swift --version
Swift version 5.10 (swift-5.10-RELEASE)
Target: x86_64-unknown-linux-gnu
root@c723e86e0fc3:~# swift repl
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/lldb/__init__.py", line 1399, in <module>
    eTraceInstructionControlFlowTypeInstruction = _lldb.eTraceInstructionControlFlowTypeInstruction
AttributeError: module '_lldb' has no attribute 'eTraceInstructionControlFlowTypeInstruction'
Welcome to Swift version 5.10 (swift-5.10-RELEASE).
Type :help for assistance.
  1> import Foundation 
  2. let s = NSMutableArray() 
  3. s.add(2) 
  4. s.remove(2) 
  5. print(s.description)
(
    2
)
s: Foundation.NSMutableArray = {
  Foundation.NSArray = {
    Foundation.NSObject = {}
    _cfinfo = {
      info = 4992
      pad = 0
    }
    _storage = 1 value {
      [0] = {
        Foundation.NSValue = {
          Foundation.NSObject = {}
        }
        _base = {
          info = 5762
          pad = 0
        }
        _pad = 2
      }
    }
  }
}