crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Some `IO::FileDescriptor` methods are implemented in `Crystal::System::File`

Open HertzDevil opened this issue 4 months ago • 0 comments

flowchart BT
File --> IO::FileDescriptor
File --> Crystal::System::File
IO::FileDescriptor --> Crystal::System::FileDescriptor

These methods of IO::FileDescriptor are implemented in Crystal::System::File instead of Crystal::System::FileDescriptor:

  • #fsync -> #system_fsync
  • #flock_shared -> #system_flock_shared
  • #flock_exclusive -> #system_flock_exclusive
  • #flock_unlock -> #system_flock_unlock

Thus it is always a compilation error to call them on IO::FileDescriptors that aren't Files:

STDOUT.fsync            # Error: undefined method 'system_fsync' for IO::FileDescriptor
IO.pipe[0].flock_shared # Error: undefined method 'system_flock_shared' for IO::FileDescriptor

Either the methods in IO::FileDescriptor should be moved down to File, or the #system_ implementations should be moved to Crystal::System::FileDescriptor.

HertzDevil avatar Feb 20 '24 11:02 HertzDevil