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

check for nil #351

Closed
wants to merge 1 commit into from
Closed

Conversation

blewis-foreflight
Copy link

Fixes #

Changes proposed in this PR

  • In certain environments, fseeko(result, 0, SEEK_END) will fail to build if result is optional. Added a requirement for result to be non-nil

Tests performed

Further info for the reviewer

Open Issues

@weichsel
Copy link
Owner

weichsel commented Feb 3, 2025

Hi Ben,
Thanks for contributing this PR.

In certain environments, fseeko(result, 0, SEEK_END) will fail to build if result is optional.

Which environment is this? Because your change breaks the build for all currently supported environments (Darwin, Linux).
Can you conditionally enable your change with a compiler directive?

@blewis-foreflight
Copy link
Author

Hi Ben, Thanks for contributing this PR.

In certain environments, fseeko(result, 0, SEEK_END) will fail to build if result is optional.

Which environment is this? Because your change breaks the build for all currently supported environments (Darwin, Linux). Can you conditionally enable your change with a compiler directive?

Hi Thomas, it was a docker build. I can try to find more details. That's very strange.
Output from build server:

#19 12.30 /app/.build/checkouts/ZIPFoundation/Sources/ZIPFoundation/Archive+MemoryFile.swift:45:20: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') #19 12.30 43 | #endif #19 12.30 44 | if append { #19 12.30 45 | fseeko(result, 0, SEEK_END) #19 12.30 | |- error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') #19 12.30 | |- note: coalesce using '??' to provide a default when the optional value contains 'nil' #19 12.30 | - note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
#19 12.30 46 | }
#19 12.30 47 | return result
#19 ERROR: process "/bin/sh -c swift build -c release && mv swift build -c release --show-bin-path /build/bin" did not complete successfully: exit code: 1

[builder 8/8] RUN swift build -c release && mv swift build -c release --show-bin-path /build/bin:
#19 12.30 [106/949] Compiling ZIPFoundation Archive+BackingConfiguration.swift
#19 12.30 /app/.build/checkouts/ZIPFoundation/Sources/ZIPFoundation/Archive+MemoryFile.swift:45:20: error: value of optional type 'UnsafeMutablePointer?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer' (aka 'UnsafeMutablePointer<_IO_FILE>')
#19 12.30 43 | #endif
#19 12.30 44 | if append {
#19 12.30 45 | fseeko(result, 0, SEEK_END)
#19 12.30 | |- error: value of optional type 'UnsafeMutablePointer?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer' (aka 'UnsafeMutablePointer<_IO_FILE>')
#19 12.30 | |- note: coalesce using '??' to provide a default when the optional value contains 'nil'
#19 12.30 | - note: force-unwrap using '!' to abort execution if the optional value contains 'nil' #19 12.30 46 | } #19 12.30 47 | return result

@fortmarek
Copy link

I ran into the same error. Targeting ZIPFoundation latest commit on the development branch resolved the issue for us. Most likely the issue got fixed by e29b053

@weichsel any chance you'd be able to release a new version of the library?

@blewis-foreflight
Copy link
Author

I ran into the same error. Targeting ZIPFoundation latest commit on the development branch resolved the issue for us. Most likely the issue got fixed by e29b053

@weichsel any chance you'd be able to release a new version of the library?

Same. Confused me for a minute since when I cloned the repo and looked for the line that was the issue, it was "gone" :)

@weichsel
Copy link
Owner

weichsel commented Feb 7, 2025

@weichsel any chance you'd be able to release a new version of the library?

Are you experiencing the build issue with the current release version or did you build some state of development?

@fortmarek
Copy link

fortmarek commented Feb 7, 2025

Are you experiencing the build issue with the current release version or did you build some state of development?

The build issue does occur with the latest release. The build issue does not occur when building the latest commit from the development branch.

Which is why a new release would be really appreciated here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants