JSON boolean sentinel $JSON::true becomes undef on both backends
还没有人认领这个 Issue。
评估
调研方向
从 JSON/JSON::PP 的加载和包变量处理路径开始,使用 t/children.t 中的测试 8-9 以及最小复现用例作为行为参考。在系统 Perl、JVM 后端和解释器下比较结果。当 $JSON::true 和 $JSON::false 保持标准值、解码后的布尔值能够正确比较,并且存在一个由项目维护的永久回归测试时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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-Simplev3.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/NOKflags 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.
- 主要语言
- Perl
- 星标
- 64
- 派生
- 6
- 平均合并
- 5 小时 38 分钟
- 30 天内合并 PR
- 170
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fglock/PerlOnJava 的其他 Issue
-
area:cpan-port area:unicode bug
难度 2/5 1-3 小时 新手友好度 88/100
fglock/PerlOnJava#1341 ·
-
area:backend area:runtime bug
难度 4/5 3-5 天 新手友好度 45/100
fglock/PerlOnJava#1511 ·
-
area:backend area:cpan-port bug
难度 4/5 3-5 天 新手友好度 45/100
fglock/PerlOnJava#1508 · 1 条评论 ·
-
area:cpan-port area:platform enhancement
难度 5/5 一周以上 新手友好度 30/100
fglock/PerlOnJava#1507 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
fglock/PerlOnJava#1506 ·
查看 fglock/PerlOnJava 的全部 Issue
相似的 Issue
-
documentation Needs Triage
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
trizen/youtube-viewer#456 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
connectivity 未关闭
难度 1/5 1 小时以内 新手友好度 80/100
-
Common US ingredient names are not recognized, so about 12.4k US products miss an allergen warning 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
openfoodfacts/openfoodfacts-server#14657 · 4 条评论 ·