Repository navigation
vm(images): Image.open takes no block, and wiring one would call a filter - #958
Merged
Merged
Conversation
…lter #950's second half asked whether Images::Image.open discarding its block is a gap, the way the socket doors' discarded blocks were (#931/#932: 27 hung spec files) and Augeas.open's was (#952). The row in testdata/open-doors.txt said "UNSPECIFIED, not a known defect" because nobody had read the reference. Read now. go-ruby-images' README calls itself "a MiniMagick / ruby-vips replacement", and MiniMagick's lib/mini_magick/image.rb declares: def self.open(path_or_url, ext = nil, **options) with NO block parameter — no `yield`, no `block_given?`, no `ensure`. The only blocks in its body are internal, handed to `uri.open` and `pathname.open`. ruby-vips has no `Image.open` at all; it spells this `Vips::Image.new_from_file`. A Ruby method that takes no block and is handed one ignores it, so rbgo is already right. Nothing to fix. ⛔⛔ AND THE "FIX" WOULD BE WORSE THAN POINTLESS. socketOpenWithBlock closes through the CLASS'S OWN `close`, and on Images::Image `close` is the MORPHOLOGICAL CLOSING operator — dilate then erode, taking a radius — exactly as `#open` is morphological opening. Wrapping the door would run an image filter on the way out of every block, believing it had released something. That is measured, not reasoned: wiring it makes the program die with ArgumentError: wrong number of arguments (given 0, expected 1) raised by that operator, called with no radius from the helper's defer. So three things land, none of them a behaviour change: - TestImagesImageOpenTakesNoBlock pins the contract. Without it the correct behaviour is INDISTINGUISHABLE from the defect it resembles: three other `open` doors that discarded a block were real bugs, so the next reader has every reason to assume a fourth. It asserts both halves a yield-only change would get wrong — the block does not run, and `open` answers the IMAGE, not the block's value. - the open-doors row is upgraded from UNSPECIFIED to reference-read, and says why the door STAYS listed: the row is what protects a correct door from being repaired. - socketOpenWithBlock's comment now states the assumption it was carrying silently — that `close` means "release" on the class being wrapped — with this counter-example. Nothing in the helper can tell the two meanings apart, since a native checks its own arguments and even arity is not introspectable; the door table is the check that can, so the instruction is to read what a new class's `close` does before wrapping it. ⛔ What I did NOT file, having looked: rbgo's `Image.open` takes one argument where MiniMagick takes `(path_or_url, ext = nil, **options)`, and `imagesArity` is a MINIMUM, so a second argument is silently ignored rather than refused. That is cosmetic for decoding — go-ruby-images' Open calls image.Decode, which SNIFFS the format from content via the registered PNG/JPEG/GIF/BMP/TIFF/WebP decoders, so the `ext` hint changes nothing either way. The URL half is a real gap (MiniMagick fetches http/https/ftp) and is #957 rather than smuggled in here, because implementing it gives the interpreter an outbound fetch driven by a path-shaped argument — a judgement for the maintainer, not a parity checkbox. Verified by mutation, not by reading: wiring the door red-lines BOTH gates independently — the behavioural test, and the ratchet, which reports the row as one that no longer needs one. Reverted, both green. gofmt clean, buildscan --vet under all 19. Closes #950 Refs #957, #931, #932, #952 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reference settles it the other way: there is no block form
#950's second half asked whether
Images::Image.opendiscarding its block is a gap, the way the socket doors' discarded blocks were (#931/#932 — 27 hung spec files) andAugeas.open's was (#952). The row intestdata/open-doors.txtsaid "UNSPECIFIED, not a known defect" because nobody had read the reference.Read now. go-ruby-images' README calls itself "a MiniMagick / ruby-vips replacement", and MiniMagick's
lib/mini_magick/image.rbdeclares:No block parameter — no
yield, noblock_given?, noensure. The only blocks in its body are internal, handed touri.openandpathname.open. ruby-vips has noImage.openat all; it spells thisVips::Image.new_from_file.A Ruby method that takes no block and is handed one ignores it. rbgo is already right, and there is nothing to fix.
⛔⛔ And the "fix" would be worse than pointless
socketOpenWithBlockcloses through the class's ownclose— and onImages::Image,closeis the morphological closing operator: dilate then erode, taking a radius.#openis morphological opening for the same reason; the name collision is on both.Wrapping the door would run an image filter on the way out of every block, believing it had released something. Measured, not reasoned — wiring it makes the program die with:
raised by that operator, called with no radius from the helper's
defer.What lands — no behaviour change
TestImagesImageOpenTakesNoBlockopendoors that discarded a block were real bugs, so the next reader has every reason to assume a fourth. It asserts both halves a yield-only change would get wrong — the block does not run, andopenanswers the image, not the block's valueopen-doors.txtrowsocketOpenWithBlock's commentclosemeans release on the class being wrapped — with this counter-exampleNothing in the helper can tell the two meanings apart: a native checks its own arguments, so even arity is not introspectable. The check that can is the door table plus
TestEveryOpenDoorIsAccountedFor, so the instruction added is to read what a new class'sclosedoes before wrapping it.Verified by mutation, not by reading
Wiring the door red-lines both gates, independently:
TestImagesImageOpenTakesNoBlock— the program dies in the helper's deferredcloseTestEveryOpenDoorIsAccountedFor— "holds 1 row(s) for door(s) that no longer need one"Reverted, both green.
gofmt -l .prints nothing;buildscan --dir . --vet→ "go vet passed under all 19", re-run on a tree verified identical to the commit after a comment edit landed during the first run.⛔ What I looked at and did not file here
ext: MiniMagick takesext = nil; rbgo ignores a second argument, sinceimagesArityis a minimum. Cosmetic — go-ruby-images'Opencallsimage.Decode, which sniffs the format from content through the registered PNG/JPEG/GIF/BMP/TIFF/WebP decoders, so the hint changes nothing on either side.openfetcheshttps?|ftp; rbgo's decodes a file. A real gap, and Images::Image.open takes a path where MiniMagick takes a path OR a URL, and implementing it is an outbound-fetch surface #957 rather than smuggled in here — implementing it gives the interpreter an outbound fetch driven by a path-shaped argument, which is a judgement for the maintainer, not a parity checkbox.Dispositions
Closes #950
Closes #950
Refs #957, #931, #932, #952
#950 is finished: its Augeas half landed in #952, and this settles the Images half as not-a-defect. #957 is the separate divergence the same reading turned up and stays open. #931, #932 and #952 are named as the three real block-discarding bugs this one resembles and is not.
🤖 Generated with Claude Code