Interpreter bypasses overloaded logical negation

未關閉
#2,122 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
47/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java, perl
領域
backend, testing

研究方向

Start with CompileOperator.visitOperator, the interpreter’s NOT handler, and MathOperators.not()/Overload.bool_not() to trace how overloaded negation differs across backends. First run the focused reproducer and the unchanged Math-Logic 1.19 t/logic.t suite on system Perl, the JVM backend, and the interpreter. Done means a project regression passes on both backends, raw negation still works under no overloading, and all 332 upstream assertions pass.

由索引模型根據 Issue 內容生成。

描述

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

Summary

Math::Logic 1.19's upstream t/logic.t fails five assertions under PerlOnJava when negating overloaded objects with !. System Perl passes the complete suite. A focused reproducer confirms that the PerlOnJava interpreter returns a plain boolean instead of invoking the class's overloaded ! method.

Evidence

  • CPAN random-tester run: 20261119-133823-51077.
  • Distribution: pure-Perl Math-Logic 1.19; no XS/native dependency.
  • System Perl 5.42.2: t/logic.t passes all 332 tests.
  • PerlOnJava: 5/332 tests fail (tests 230, 260, 278–280), all in ! assertions for three-valued or multi-valued logic. The same failures reproduce with the JVM-default launcher and --interpreter on source 543f9dfef.
  • Focused reducer: system Perl and the JVM backend return a Math::Logic object for the overloaded negation; the interpreter returns a scalar and fails the result-type/value assertion.
use Math::Logic qw($UNDEF);
my $x = Math::Logic->new(-value => $UNDEF, -degree => 3, -propagate => 1);
my $negated = !$x;
die "expected Math::Logic result\n"
    unless ref($negated) eq 'Math::Logic' && $negated == $UNDEF;

Root cause

The interpreter compiler emits Opcodes.NOT when overloading is enabled (CompileOperator.visitOperator). The interpreter's NOT handler currently calls RuntimeScalar.getBoolean() and stores a cached plain true/false scalar. It does not route through MathOperators.not() or Overload.bool_not(), so it skips the (! overload. NOT_NO_OVERLOAD is a separate opcode and should remain the raw-boolean path.

The JVM implementation routes logical negation through MathOperators.not(), which calls Overload.bool_not() for overloaded values. The focused JVM reducer passes, but the complete upstream test still fails five assertions through the default launcher. That state-dependent full-suite failure must also be reduced and resolved before claiming distribution compatibility.

Acceptance criteria

  • Add a project-owned regression for overloaded !, validate it with system Perl first, and make it pass on the JVM and interpreter.
  • Preserve raw boolean behavior under no overloading.
  • Reduce and resolve the five full-suite failures, including the discrepancy between the passing focused JVM case and failing t/logic.t run.
  • Pass the unchanged Math-Logic 1.19 t/logic.t suite (332/332) on both PerlOnJava backends.

Related issue search

No existing issue was found for overloaded unary !. #2074 covers separate Set::Scalar parser and binary-operation failures; #2007 covers recursive re-dispatch of an active overload handler.

主要語言
Perl
星號
67
分支
8
平均合併
5 小時 12 分鐘
30 天內合併 PR
131

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

fglock/PerlOnJava 的其他 Issue

查看 fglock/PerlOnJava 的全部 Issue

相似的 Issue

更多 Perl Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。