From 57177d737cd9cf2aca1fc684bedb013591e958f9 Mon Sep 17 00:00:00 2001 From: Richard Rodger Date: Fri, 11 Sep 2026 19:37:28 +0100 Subject: [PATCH] perl: say which perl version is required, once, where it is required MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On perl 5.34 loading this port reports Can't locate builtin.pm in @INC (you may need to install the builtin module) ... at lib/Voxgig/Plugin/Types.pm line 25. and then unwinds through a BEGIN failure for every module on the way down — eight of them when the library is loaded through a host SDK — naming each file and never the requirement. `builtin` is core from 5.36 and does not exist before it, so there is no module to install and the advice is a dead end. The README already states the minimum. Nothing in the CODE did, so the one person who most needs to be told read the least useful message. A version check now states it in one line, at the one file that depends on it: `is_bool` is the only way perl can tell a true boolean from the number 1, and `jsontype` is the whole of this port's answer to having no JSON types. The runner carries the check too. `Corpus.pm` loads `builtin` BEFORE it loads the library, so the suite would reach the cryptic error first and the library's own message never. A BEGIN block rather than `use v5.36`, which would also switch on that release's feature bundle and change how the rest of each file compiles. Verified on this machine's 5.34 — both files now die with the intended sentence instead of the cascade — and the block itself parses clean. CI runs this port on the image's perl 5.38, which is where the change proves it did not break a supported interpreter. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01619YNVDt9KUSx25NZA6ADi --- perl/lib/Voxgig/Plugin/Types.pm | 24 ++++++++++++++++++++++++ perl/test/Corpus.pm | 14 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/perl/lib/Voxgig/Plugin/Types.pm b/perl/lib/Voxgig/Plugin/Types.pm index 7df5d3f..557d1b9 100644 --- a/perl/lib/Voxgig/Plugin/Types.pm +++ b/perl/lib/Voxgig/Plugin/Types.pm @@ -19,6 +19,30 @@ use strict; use warnings; use B (); use Scalar::Util qw(blessed reftype); + +# PERL 5.36 OR LATER, SAID ONCE, HERE. +# +# `builtin` is core from 5.36 and does not exist before it, so on 5.34 the +# interpreter reports `Can't locate builtin.pm` and then unwinds through a +# BEGIN failure for every module on the way down — eight of them when the +# library is loaded through a host — naming each file and never the +# requirement. The README states the minimum; nothing in the code did, so +# the one person who most needs to be told reads the least useful message. +# +# This is the file that depends on it: `is_bool` is the only way perl can +# tell a true boolean from the number 1, and `jsontype` below is the whole +# of the port's answer to having no JSON types. +# +# A BEGIN block rather than `use v5.36`, which would also switch on that +# release's feature bundle and change how the rest of this file compiles. +BEGIN { + if ($] < 5.036) { + die "Voxgig::Plugin::Types requires perl 5.36 or later (this is $]):" + . " it uses builtin::is_bool, the only way perl can tell a true" + . " boolean from the number 1.\n"; + } +} + use builtin qw(is_bool); no warnings 'experimental::builtin'; diff --git a/perl/test/Corpus.pm b/perl/test/Corpus.pm index 0fea8a5..623c370 100644 --- a/perl/test/Corpus.pm +++ b/perl/test/Corpus.pm @@ -17,6 +17,20 @@ use File::Basename qw(dirname); use File::Spec; use JSON::PP (); use B (); + +# PERL 5.36 OR LATER, for the same `builtin::is_bool` the library needs and +# for the same reason — see Voxgig::Plugin::Types, which carries the full +# note. Stated again here because this file loads `builtin` BEFORE it loads +# the library, so on 5.34 the runner would reach the cryptic +# `Can't locate builtin.pm` first and the library's own message never. +BEGIN { + if ($] < 5.036) { + die "the perl corpus runner requires perl 5.36 or later" + . " (this is $]): it uses builtin::is_bool, the only way perl" + . " can tell a true boolean from the number 1.\n"; + } +} + use builtin qw(is_bool); no warnings 'experimental::builtin'; use Voxgig::Plugin qw(codeof);