Skip to content

correctness: CHECK_IS_FALSE and CHECK_IS_NULL return identical undef #86

@Koan-Bot

Description

@Koan-Bot

Summary

FT_RETURNNO is defined in FileCheck.h but never used. The XS handler pp_overload_ft_yes_no maps CHECK_IS_FALSE (0) to FT_RETURNUNDEF instead of FT_RETURNNO, making CHECK_IS_FALSE and CHECK_IS_NULL indistinguishable from the caller's perspective.

Impact

In Perl, file-test operators have two distinct "false" results:

  • Defined false (''): "check failed but file is known" — e.g., -f "/tmp" (a directory)
  • Undef: "file not found / unknown" — e.g., -e "/nonexistent"

Users can distinguish these with defined(). With the current code:

mock_file_check('-f', sub { CHECK_IS_FALSE });
defined(-f "something")  # returns false — WRONG, should be true

The XS comment at line 68-71 documents the intended behavior correctly:

*  0 check is false -> OP returns No
* -2 check is null  -> OP returns undef

But the implementation at line 270 doesn't match:

if ( check_status == 0 )  FT_RETURNUNDEF;  // should be FT_RETURNNO

Fix

PR #85

🤖 Created by Kōan from audit session

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions