Honor scalar context for sort returned from a subroutine

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

維護者通常 1 天內回覆

@fglock 已經在處理了。

開始於 2026年11月6日。

  • #1992 來自 @fglock —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
perl
領域
backend

研究方向

Start by reviewing PR #1992, which is already open and describes the fix across the JVM and interpreter backends. Trace how a subroutine return passes runtime context to sort, then run the focused regression and scalar-sort tests on both backends. Done means scalar callers receive Perl's undef result while list behavior remains covered.

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

描述

area:runtime bug

Summary

sort in a subroutine return did not honor the caller's scalar context. Perl returns undef for sort in scalar context, but PerlOnJava returned the number of sorted values. This broke DataCube 0.01's tables method, which returns sort keys ... and is called in scalar context by its test suite.

Minimal reproducer

sub f { return sort qw(a b c) }
my $x = f();
print defined($x) ? "<$x>\n" : "undef\n";

Expected under system Perl: undef

Before the fix, PerlOnJava returned <3> on both JVM and interpreter backends.

Evidence

  • CPAN distribution: DataCube 0.01; random tester run 20261106-154847-45334.
  • System Perl 5.42.2: upstream make test passed, 26 tests.
  • PerlOnJava 5.44.1, build commit 13db7bd4a0: t/00_use.t exited 255 on both JVM and interpreter after 15 assertions, with Can't use string ("40") as a HASH ref.
  • The DataCube test assigns $cube->tables to a scalar. DataCube::tables returns sort keys ...; the scalar result was then treated as a hash reference.

Confirmed cause and fix

Static scalar-context sort was already handled. In a subroutine return, however, the caller's context is dynamic: PerlOnJava retained the sorted list and generic return handling scalarized it to the list length. PR #1992 passes the runtime context to sort on both backends, preserving input evaluation while skipping the comparator and returning undef for a scalar caller.

The focused regression and existing scalar-sort tests pass on system Perl, JVM, and interpreter. The full repository make and documentation link check pass. The DataCube suite progresses beyond the former failure, but later tests exceed the bounded 180-second runs; a full post-fix DataCube suite pass is not claimed.

主要語言
Perl
星號
65
分支
8
平均合併
5 小時 57 分鐘
30 天內合併 PR
177

環境準備

  • 提供 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 摘要。