# Exists\_file/1 in v9.0.4 is broken

**URL:** <https://swi-prolog.discourse.group/t/exists-file-1-in-v9-0-4-is-broken/6405>\
**Category:** General\
**Tags:** bug\
**Created:** [March 25, 2023, 4:56pm UTC](https://swi-prolog.discourse.group/t/exists-file-1-in-v9-0-4-is-broken/6405 "2023-03-25T16:56:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![duesentrieb17](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/duesentrieb17/32/4333_2.png) [@duesentrieb17](https://swi-prolog.discourse.group/u/duesentrieb17)\
**Post date:** [March 25, 2023, 4:56pm UTC](https://swi-prolog.discourse.group/t/exists-file-1-in-v9-0-4-is-broken/6405/1 "2023-03-25T16:56:49Z")

</div>

Hi Jan,

v5.9.7:

```prolog
1 ?- exists_file('').
false.

```

v.9.0.4:

```prolog
?- exists_file('').
ERROR: Domain error: `foreign_return_value' expected, found `-1'
ERROR: In:
ERROR: [10] exists_file('')
ERROR: [9] toplevel_call(user:user: ...) at c:/programs/swi-prolog/v9.0.4-1/boot/toplevel.pl:1173

```

I think the v.5.9.7 is right.

Cheers  
Holger

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 26, 2023, 11:51am UTC](https://swi-prolog.discourse.group/t/exists-file-1-in-v9-0-4-is-broken/6405/2 "2023-03-26T11:51:50Z")

</div>

The error is surely wrong. It doesn’t reproduce, neither under Wine nor on Windows 11. It is quite easy to see why this could happen though. Pushed a fix and documented the behavior that using an illegal name (such as a too long name) causes this predicate to fail silently.

I don’t know whether that is good or bad. On the one hand one could argue that it is better to raise an appropriate exception for an invalid name. On the other hand, we have seen that the Windows error codes are often wrong. And, one could argue that there is indeed no file with that name because the name is invalid and (thus) that file cannot exist. This, while it _could_ exist on another system that can represent the file name.

---

<div class="post-metadata">

**Author:** ![duesentrieb17](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/duesentrieb17/32/4333_2.png) [@duesentrieb17](https://swi-prolog.discourse.group/u/duesentrieb17)\
**Post date:** [March 28, 2023, 5:25pm UTC](https://swi-prolog.discourse.group/t/exists-file-1-in-v9-0-4-is-broken/6405/3 "2023-03-28T17:25:27Z")

</div>

Hi Jan,

thanks for the quick support!

Cheers  
Holger
