Lexical sub calls from named subs lose their binding (Test2::Tools::DOM 0.100)

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

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

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

研究方向

Start by reproducing the failure with ./jperl -Ilib -I/private/tmp/cpan-module-classification/Mojo-DOM58-3.003/lib t/html.t, using lib/Test2/Tools/DOM.pm (lexical my sub call and my sub multi at lines 29 and 44, called from named subs) purely as the trigger. The real work is in the compiler's handling of lexical subs referenced from named subs — trace where named subs are compiled and how their pad/closure captures are built, since that is where the binding is dropped. Done means standard-Perl behaviour: no will not stay shared warnings and the t/html.t and t/synopsis.t tests passing.

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

描述

area:cpan-port area:parser area:runtime bug

Module

  • Distribution: Test2-Tools-DOM 0.100
  • CPAN tester report: syntax error, 2026-10-25
  • System Perl: /usr/bin/perl 5.34.1 on macOS arm64; prove -lr t/ passes 3 files / 12 tests (with cached Mojo::DOM58 3.003 added only to PERL5LIB).
  • PerlOnJava: timeout 120 ./jperl -Ilib -I/private/tmp/cpan-module-classification/Mojo-DOM58-3.003/lib t/html.t fails (10 test failures); t/synopsis.t aborts on first call.

Reproducer and cause

lib/Test2/Tools/DOM.pm declares lexical subs my sub call and my sub multi at lines 29 and 44, then calls them from named package subs (all_text, tag, attr, etc.). PerlOnJava emits Subroutine "&call" will not stay shared / &multi warnings for these references; at runtime the lexical CV is absent and calls fail with Undefined subroutine &Test2::Tools::DOM::call called (or multi) at lines 65/69.

This isolates the failure to lexical-sub binding/capture across named subroutine bodies: the compiler is treating references to lexically declared subs as closure-pad captures that are not preserved in the named subs. Standard Perl resolves these lexical sub calls correctly. The failure happens before DOM assertion behavior is exercised.

Expected

Lexical sub references from named subs retain the lexical subroutine binding and execute as on standard Perl, without undefined-subroutine errors.

主要語言
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 摘要。