Skip to content

vm(images): Image.open takes no block, and wiring one would call a filter - #958

Merged
tannevaled merged 1 commit into
mainfrom
images-open-reference
Nov 17, 2026
Merged

tannevaled merged 1 commit into
mainfrom
images-open-reference

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The reference settles it the other way: there is no block form

#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)

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. rbgo is already right, and there is 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. #open is 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:

ArgumentError: wrong number of arguments (given 0, expected 1)

raised by that operator, called with no radius from the helper's defer.

What lands — no 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.txt row 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: 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's close does 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 deferred close
  • TestEveryOpenDoorIsAccountedFor — "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 takes ext = nil; rbgo ignores a second argument, since imagesArity is a minimum. Cosmetic — go-ruby-images' Open calls image.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.
  • URLs: MiniMagick's open fetches https?|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

…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>
@tannevaled
tannevaled merged commit 957457a into main Nov 17, 2026
26 checks passed
@tannevaled
tannevaled deleted the images-open-reference branch November 17, 2026 14:01
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.

Images::Image.open discards its block and has no known reference — the Augeas half was never blocked, see #952

1 participant