From e6620faad31f35d28af8d60d2ee0db85ba103334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Tue, 15 Aug 2023 16:05:11 +0200 Subject: [PATCH] Fix check for file type --- spec/compiler/crystal_path/crystal_path_spec.cr | 3 +++ spec/compiler/crystal_path/foo.cr/foo.cr | 0 src/compiler/crystal/crystal_path.cr | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 spec/compiler/crystal_path/foo.cr/foo.cr diff --git a/spec/compiler/crystal_path/crystal_path_spec.cr b/spec/compiler/crystal_path/crystal_path_spec.cr index d9ecb3f0b9f2..fa2091223d54 100644 --- a/spec/compiler/crystal_path/crystal_path_spec.cr +++ b/spec/compiler/crystal_path/crystal_path_spec.cr @@ -68,6 +68,9 @@ describe Crystal::CrystalPath do assert_finds "../test_folder", relative_to: "test_files/test_folder/file_three.cr", results: [ "test_files/test_folder/test_folder.cr", ] + assert_finds "foo.cr", results: [ + "foo.cr/foo.cr", + ] # For `require "foo"`: # 1. foo.cr (to find something in the standard library) diff --git a/spec/compiler/crystal_path/foo.cr/foo.cr b/spec/compiler/crystal_path/foo.cr/foo.cr new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/compiler/crystal/crystal_path.cr b/src/compiler/crystal/crystal_path.cr index 6ba5b96033ef..e957a513a714 100644 --- a/src/compiler/crystal/crystal_path.cr +++ b/src/compiler/crystal/crystal_path.cr @@ -120,7 +120,7 @@ module Crystal each_file_expansion(filename, relative_to) do |path| absolute_path = File.expand_path(path, dir: @current_dir) - return absolute_path if File.exists?(absolute_path) + return absolute_path if File.file?(absolute_path) end nil