From c30411fc078659e6e4a3488ac6d569fb1c1db3a0 Mon Sep 17 00:00:00 2001 From: James E Keenan Date: Wed, 7 May 2025 11:30:07 -0400 Subject: [PATCH] Ensure that when variable is used, it has been initialized There were cases discovered during smoke-testing on OpenBSD since fecfa476ebe was committed in February 2025 where $locale was undefined and emitting a runtime warning. --- t/run/locale.t | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/run/locale.t b/t/run/locale.t index 89b136377e1c..46d3cd4fbf0b 100644 --- a/t/run/locale.t +++ b/t/run/locale.t @@ -592,7 +592,7 @@ SKIP: { skip "didn't find a suitable non-UTF-8 locale", 1 unless @non_utf8_locales; - my $locale = $non_utf8_locales[0]; + my $locale = $non_utf8_locales[0] // ''; fresh_perl_is(<<"EOF", "ok\n", {}, "cmp() handles above Latin1 and NUL in non-UTF8 locale"); use locale; @@ -613,7 +613,7 @@ EOF SKIP: { skip "didn't find a suitable UTF-8 locale", 1 unless $utf8_ref; - my $locale = $utf8_ref->[0]; + my $locale = $non_utf8_locales[0] // ''; fresh_perl_is(<<"EOF", "ok\n", {}, "Handles above Unicode in a UTF8 locale"); use locale; @@ -636,7 +636,7 @@ SKIP: my $is64bit = length sprintf("%x", ~0) > 8; skip "32-bit ASCII platforms can't physically have extended UTF-8", 1 if $::IS_ASCII && ! $is64bit; - my $locale = $utf8_ref->[0]; + my $locale = $non_utf8_locales[0] // ''; fresh_perl_is(<<"EOF", "ok\n", {}, "cmp() handles Perl extended UTF-8"); use locale; @@ -686,7 +686,7 @@ SKIP: { # GH #20054 && $Config{d_setlocale_accepts_any_locale_name} eq 'define'; my @lc_all_locales = find_locales('LC_ALL'); - my $locale = $lc_all_locales[0]; + my $locale = $non_utf8_locales[0] // ''; skip "LC_ALL not enabled on this platform", 1 unless $locale; my $fallback = ($^O eq "MSWin32") ? "system default"