Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

JSON boolean sentinel $JSON::true becomes undef on both backends

Đang mở
#1,392 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
perl
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu với các đường dẫn tải và xử lý biến package của JSON/JSON::PP, sử dụng các test 8-9 trong t/children.t và trình tái hiện tối giản làm tham chiếu hành vi. So sánh kết quả trên Perl hệ thống, backend JVM và trình thông dịch. Được xem là hoàn tất khi $JSON::true và $JSON::false giữ nguyên các giá trị chuẩn, các boolean đã giải mã được so sánh chính xác và có một regression test lâu dài do dự án sở hữu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area:backend area:cpan-port area:runtime bug

Summary

PerlOnJava mishandles the package variable $JSON::true when a JSON boolean is
decoded. The decoded value is a JSON::PP::Boolean, but $JSON::true becomes
undef in both execution backends. This breaks standard Perl identity/equality
semantics and causes upstream CPAN tests to fail.

CPAN evidence

  • Distribution: Net-Google-Drive-Simple v3.02
  • CPAN run: 20260915-125610-17469
  • Failure record: FAIL Net::Google::Drive::Simple Net::Google::Drive::Simple
  • Failing test: t/children.t, tests 8-9
  • PerlOnJava result: 93/95 assertions pass; 2 fail in 1/12 test programs
  • System Perl: the equivalent JSON boolean comparison passes
  • Environment: pure-Perl target distribution; no target XS/native code
  • Backends: reproduced on both the JVM backend and the interpreter

The failing upstream assertion is:

ok $JSON::true;
is $first_file->copyable, $JSON::true, "copyable is true";

The first assertion fails because $JSON::true is false/undefined. The second
reports an actual JSON::PP::Boolean object but an expected undef value.

Minimal reproducer

use JSON;
use Test2::V0;

my $json = JSON->new;
my $value = $json->decode('{"copyable":true}');

ok $JSON::true;
is $value->{copyable}, $JSON::true, 'JSON true';
done_testing;

Expected under standard Perl:

ok 1
ok 2 - JSON true
1..2

Observed on both PerlOnJava backends:

not ok 1
not ok 2 - JSON true
GOT:   JSON::PP::Boolean=SCALAR(...)
CHECK: undef
1..2

Impact

Code using JSON's documented boolean sentinels can incorrectly treat true as
false or undefined. This affects API clients, configuration readers, feature
flags, permission checks, and any CPAN module that compares decoded JSON
booleans with $JSON::true or $JSON::false. In this distribution it causes
the copyable property of a decoded Google Drive item to be reported
incorrectly by its test suite.

Likely ownership

The failure is not caused by Net::Google::Drive::Simple: the same JSON
boolean semantics pass under system Perl, and the distribution's other 11 test
programs pass on PerlOnJava. The behavior points to package-variable handling
or JSON boolean initialization/runtime state in PerlOnJava. It is shared by
the JVM and interpreter backends.

Expected fix

Preserve the standard Perl behavior of $JSON::true and $JSON::false after
loading JSON/JSON::PP, including comparisons against decoded boolean
values. Add a permanent project-owned regression test for the reproducer and
run it under system Perl, the JVM backend, and the interpreter backend.

Deduplication

I searched all GitHub issues for JSON::true, JSON::PP::Boolean,
package variable undef boolean, and Net::Google::Drive::Simple.

  • No existing issue directly covers this $JSON::true/JSON boolean failure.
  • #1352 concerns incorrect IOK/NOK flags for large floating-point values;
    it is adjacent scalar-typing work but has a different reproducer and impact.
  • #1260, #1262, and #1308 concern other scalar typing or dual-value cases and
    do not cover JSON boolean package variables.

This issue is therefore not a duplicate.

Ngôn ngữ chính
Perl
Star
64
Fork
6
Merge trung bình
5 giờ 38 phút
Pull request đã merge (30 ngày)
170

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fglock/PerlOnJava

Tất cả issue của fglock/PerlOnJava

Issue tương tự

Thêm issue về Perl

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.