Skip to content

fix: Bool|Nil cast for sync= on Crystal 1.20.1#9

Open
ozgurulukir wants to merge 1 commit into
crystal-term:masterfrom
ozgurulukir:fix/sync-bool-cast
Open

fix: Bool|Nil cast for sync= on Crystal 1.20.1#9
ozgurulukir wants to merge 1 commit into
crystal-term:masterfrom
ozgurulukir:fix/sync-bool-cast

Conversation

@ozgurulukir
Copy link
Copy Markdown

Problem

IO::FileDescriptor#sync? returns Bool | Nil. Assigning the raw result to sync= raises a compile-time type error on Crystal 1.20.1 because the union type Bool | Nil is not accepted where plain Bool is expected.

The previous attempt to coerce with !! still passes the union type to the setter and fails under the same checker.

Fix

Change !!bufferingbuffering || false so the RHS is always plain Bool.

Tested

fff (crystal-port branch) builds and all 131 specs pass with this change applied locally against term-reader ~> 0.3.0.

Cc #8

 returns . Direct assignment
to  with the nilable union fails on Crystal 1.20.1 at the
type-checker level (comparable to issue crystal-term#8).

Change  →  so the RHS is always
plain , matching what the caller already did before the
partial fix that introduced .
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.

1 participant