Skip to content

Unable to load sql/utils.phel due orphaned from sql.phel at compiled form #2

@xyukafuji

Description

@xyukafuji

Dear maintainer

I, Yukari, like to thank you for hard work and reporting some strange behavior of phel/sql.

The case :

I use phel.sql as web app its work well when using php -S localhost:8080 -t public, I see no problem. Meanwhile in compiled form the translation into PHP, I encounter some error at out/phel/sql.php line 107 the translation of this line, it said :

Uncaught RuntimeException: Cannot locate sql/util for (load ...).

The code :

$__phelLoadKey = "sql/util";
$__phelCallerDir = "phel";
$__phelLoadPath = null;
$__phelSibling = __DIR__ . DIRECTORY_SEPARATOR . $__phelLoadKey . '.php';
if (file_exists($__phelSibling)) {
  $__phelLoadPath = $__phelSibling;
}
if ($__phelLoadPath === null) {
  $__phelSrcDirs = \Phel\Compiler\Domain\Analyzer\Resolver\LoadClasspath::read();
  $__phelFullKey = $__phelCallerDir === '' ? $__phelLoadKey : $__phelCallerDir . '/' . $__phelLoadKey;
  foreach ($__phelSrcDirs as $__phelSrcDir) {
    foreach ([$__phelFullKey, $__phelLoadKey] as $__phelAttempt) {
      $__phelCandidatePhp = $__phelSrcDir . '/' . $__phelAttempt . '.php';
      if (file_exists($__phelCandidatePhp)) { $__phelLoadPath = $__phelCandidatePhp; break 2; }
      $__phelCandidatePhel = $__phelSrcDir . '/' . $__phelAttempt . '.phel';
      if (file_exists($__phelCandidatePhel)) { $__phelLoadPath = $__phelCandidatePhel; break 2; }
    }
  }
}

This issue was tackled :

  • changing$__phelSibling = __DIR__ into $__phelSibling = dirname(__DIR__), or
  • manually move out/sql into out/phel so it turned into out/phel/sql

The latter way is preferred. Type of phenomenon only rise in compiled form while its not trigger in interpreted evaluation.

My assumption this happen because src/sql.phel from phel-sql not moved to out/phel, and the out/phel/sql.phel trying load sql/utils while thinking there sql folder are in same directory as itself. It not found since sql/utils.phel located at out directory not out/phel.

Thank you, End of report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions