ありがとうございます。やはり Devel::Cover は実行時の情報をキャプチャーして活用している

Tool Interactions

Tool: Bash

{
  "command": "perl examples/static_logic_analyzer.pl 2>&1",
  "description": "Run static logic analyzer"
}

Results

Result:

Possible precedence issue with control flow operator (return) at examples/static_logic_analyzer.pl line 371.
============================================================
Static Logic Structure Analyzer
============================================================

### test_simple_and:    $a && $b

Expression: $a && $b
Type: and_3
------------------------------------------------------------
| A | B | Result | Description
------------------------------------------------------------
| 0 | X |   0    | !($a)
| 1 | 0 |   0    | ($a) && !($b)
| 1 | 1 |   1    | ($a) && ($b)
------------------------------------------------------------

### test_simple_or:     $a || $b

Expression: $a || $b
Type: or_3
------------------------------------------------------------
| A | B | Result | Description
------------------------------------------------------------
| 1 | X |   1    | ($a)
| 0 | 1 |   1    | !($a) || ($b)
| 0 | 0 |   0    | !($a) || !($b)
------------------------------------------------------------

### test_or_with_const: $a || die

Expression: $a || die 'error'
Type: or_2
------------------------------------------------------------
| A | Result | Description
------------------------------------------------------------
| 1 |   1    | ($a)
| 0 |   0    | !($a)
------------------------------------------------------------

### test_complex:       ($a || $b) && $c

Expression: $b unless $a && $c
Type: and_3
------------------------------------------------------------
| A | B | Result | Description
------------------------------------------------------------
| 0 | X |   0    | !($b unless $a)
| 1 | 0 |   0    | ($b unless $a) && !($c)
| 1 | 1 |   1    | ($b unless $a) && ($c)
------------------------------------------------------------

Expression: $a || $b
Type: or_3
------------------------------------------------------------
| A | B | Result | Description
------------------------------------------------------------
| 1 | X |   1    | ($a)
| 0 | 1 |   1    | !($a) || ($b)
| 
... (truncated)

動作しました!いくつかの問題があります:

  1. xor が検出されていない - Perl 5.41.12 以降で xor が binop になった可能性
  2. B::Deparse の出力がそのまま使われているので、$b unless $a のような形式になっている
  3. 文字列からのコードでは、スコープ全体が deparse されてしまっている

これらを改善したバージョンを作成しましょう。また、より実用的なサンプルとして、論理構造の木を構築するバージョンも追加します。


uuid: assistant: 07d94729-01cc-46a5-b25a-7d9d81e1734b, assistant: 52689de9-bd19-4033-ae23-bfb6986034c3