Skip to content

Commit 0a9d143

Browse files
Avoid import var Foundation.stderr
``` $ echo "@preconcurrency import var Foundation.stderr" | swiftly run +main-snapshot-2026-08-11 swiftc - -o /dev/null <stdin>:1:28: error: ambiguous name 'stderr' in module 'Foundation' 1 | @preconcurrency import var Foundation.stderr | `- error: ambiguous name 'stderr' in module 'Foundation' 2 | Glibc.stderr:1:32: note: found this candidate 1 | nonisolated(unsafe) public var stderr: UnsafeMutablePointer<FILE>! { get } | `- note: found this candidate /usr/include/stdio.h:151:14: note: found this candidate 149 | extern FILE *stdin; /* Standard input stream. */ 150 | extern FILE *stdout; /* Standard output stream. */ 151 | extern FILE *stderr; /* Standard error output stream. */ | `- note: found this candidate 152 | /* C89/C99 say they're macros. Make them happy. */ 153 | #define stdin stdin ``` swiftlang/swift#89891
1 parent 9b9828e commit 0a9d143

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@preconcurrency import func Foundation.fputs
33
@preconcurrency import func Foundation.open
44
@preconcurrency import func Foundation.strerror
5-
@preconcurrency import var Foundation.stderr
65
@preconcurrency import var Foundation.errno
76
@preconcurrency import var Foundation.O_WRONLY
87
@preconcurrency import var Foundation.O_CREAT
@@ -15,6 +14,17 @@
1514
@preconcurrency import class Foundation.FileManager
1615
@preconcurrency import class Foundation.JSONDecoder
1716
@preconcurrency import class Foundation.ProcessInfo
17+
18+
#if canImport(Darwin)
19+
@preconcurrency import func Darwin.stderr
20+
#elseif canImport(Glibc)
21+
@preconcurrency import func Glibc.stderr
22+
#elseif canImport(Musl)
23+
@preconcurrency import func Musl.stderr
24+
#elseif canImport(Android)
25+
@preconcurrency import func Android.stderr
26+
#endif
27+
1828
import SwiftParser
1929
import SwiftSyntax
2030

Plugins/PackageToJS/Sources/PackageToJSPlugin.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88
@preconcurrency import struct Foundation.CocoaError
99
@preconcurrency import func Foundation.fputs
1010
@preconcurrency import func Foundation.exit
11-
@preconcurrency import var Foundation.stderr
11+
12+
#if canImport(Darwin)
13+
@preconcurrency import func Darwin.stderr
14+
#elseif canImport(Glibc)
15+
@preconcurrency import func Glibc.stderr
16+
#elseif canImport(Musl)
17+
@preconcurrency import func Musl.stderr
18+
#elseif canImport(Android)
19+
@preconcurrency import func Android.stderr
20+
#endif
1221
import PackagePlugin
1322

1423
/// The main entry point for the PackageToJS plugin.

0 commit comments

Comments
 (0)